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

Hello Experts, What is the difference between move and move corresponding exactly? please post me asap

1937


What is the difference beween joblib and steplib statements

2335


what is the diffrence between software and hardware language?

2387


Q1.Write a C program which asks the user for a number between 1 to 9 and shows the  number. If the user inputs a number out of the specified range, the program should  show an error and prompt the user for a valid input.

2785


When you deliver your C++ headers and C++ library of a class (what all can you change in the class so that application using your class does not need to recompile the code)

1245


A good website has the following conditions It should be interactive. It should contain at least 20 images. Title cannot be null and should contain at least 10 letters other than spaces and hyphen (-). The keywords should contain atleast three among the following list : "design", "Graphics", "lovely", "beautiful", "amazing" and "mesmerising" Write a method: boolean isGoodWebsite(boolean isInteractive, int numOfImages, String title,String keywords[]) isInteractive whether the site is interactive or not numOfImages Number of images on the website title Title of the website keywords Array of keywords in the website.

2291


Have you used callsymputx? what points need to be kept in mind when using it?

2039


what is the system development cycle

1903


how to add a new table with variables and thier values into a imported file uisng proc import?

1958


Write a program to find duplicate number from array in minimum time complexity.

1118


I want Ada programming language books. Could anyone post me any link for that?

3436


Write a program to swap the content of two variables without using a third variable.

1123


what is the similarity between networking devices?

2273


is it possible to desable particular parameter of the normal orcle report based on some condition ?????? if yes,wht is the function for desabling a parameter...

2126


sample and simple coding where we get?

2355