Skip to content

Instantly share code, notes, and snippets.

@damirstuhec
Created February 26, 2014 10:56
Show Gist options
  • Save damirstuhec/9227519 to your computer and use it in GitHub Desktop.
Save damirstuhec/9227519 to your computer and use it in GitHub Desktop.
Find the highest repeated character
int array[255] = {0};
NSString *test = @"Test string.";
int i = 0;
for(i = 0; i < test.length; i++)
{
++array[[test characterAtIndex:i]];
}
int max = array[0];
int index = 0;
for(i = 0; i < 255; i++)
{
if( array[i] > max)
{
max = array[i];
index = i;
}
}
NSLog(@"The highest repeated character is: %c", index);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment