Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

A string of charaters were given. Find the highest
occurance of a character and display that character.
eg.: INPUT: AEGBCNAVNEETGUPTAEDAGPE

Answer Posted / paindriven

char HighestCharCount(const char* str)
{

const int length = strlen(str);
if (length == 0)
return ' ';
if (length == 1)
return str[0];

int indexOfHighest = int(-1);
int highestCounter = 0;
for (int i=0; i < length; ++i)
{
const int remain = length - i;
char test = str[i];
int current = 0;
for (int j=i+1; j < remain; ++j)
{
if (str[j] == test)
{
current++;
if (current > highestCounter)
{
highestCounter = current;
indexOfHighest = i;
}
}
}
}
return str[indexOfHighest];
}

Is This Answer Correct ?    38 Yes 10 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why did you ever become involved in QA/testing?

2083


can we retrieve only integer/String type columns from a table,if yes how?

1938


what is delegate and delegation model give the real live example on delegate model

3293


how do we provide security for web services

2352


In JCl , we have COND parameter.This holds comparison code and condition.It also has only and even parameters. ex: COND((4,GE),EVEN).what the comma mean here. is that 'and' or 'or'.

2274


what are all the ant command options

2077


When we have two versions of the dot net installed how does the compiler know which version of DLL it has to select to an application.

1925


how to check single or double byte in struts

1998


Diffrence between 2.0,3.0,3.5,4.0. versions of .net?

3160


My Qualification is MCA.My interview is on 5th may.They may ask q as------AS u r MCA...Why u r not tring anywhere else? What can be the ans?

1960


HOW TO FIND NUMBER OF TWOS IN N!(N FACTORIAL)??

2281


along with oracle which language will be beneficial to have knowledge with,java,.net,since i m doing oracle have appeared for 8th sem BEIT,plz suggest

1937


a characteristic of a multiprogramming is? a.simultaneous exe of pgm instr 4m 2 appli b.concurrent processing of 2 r more prgms c.multiple cpu s d.all the abov

2202


Hi guyes, I have cleared 2 technical rounds with cts for liferay and java techonologies, i have client round next week, please tell me how to prepare for this what questions i should be ready to face?

3859


Any real time example of O2C process from taking order till creating invoice.

2381