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

suppose we have ten members of a physical file but we want the output of last 5 members only.how to achieve that?

2081


how do we provide security for web services

2343


How to call a C++ function which is compiled with C++ compiler in C code?

1302


How can recruiter justified that the candidate is expert in Algorithm and datastructure for Software product development ?

1947


what is diff bet ref variable & instance of class

1998


what is the difference between uservariables and systemvariables (in Environmental variables)???

2429


hi..this is kartheek..complted mca in 2009..but i dont have knowledge in programing..but to learn new language.. which one is suitable for me?is SAP or IBM mainframes is suitable for me..?if it suits how much will it costs..?pls answer...

1998


how we can know the funcions available in a class recording java?

2229


What's the difference b/w Table & Templete in Smartform?

2229


it is a language or tools?

2088


how to generate dsnless connectivity in j2ee

2026


4. What is the need of START 0? Instead if can we use any other numeric? If we use what will happen?

2364


Delta 5 weight scale not connect with oracle application what i can do?

2331


Explain polymorphism. Provide an example.

1028


Outline the two important features of a terminating recursion. Any ideas?

2219