Skip to content

Instantly share code, notes, and snippets.

@vikhyat
Created December 10, 2014 04:56
Show Gist options
  • Save vikhyat/a35e5c4bf656a7b9a488 to your computer and use it in GitHub Desktop.
Save vikhyat/a35e5c4bf656a7b9a488 to your computer and use it in GitHub Desktop.
main() {
char c = getchar(), t, p = -1;
int freq[128] = {0};
while ( (t = getchar()) != '\n' ) {
if (p == c)
freq[t] ++;
p = t;
}
for (t=0; t<127; t++)
if (freq[t] > freq[c])
c = t;
putchar(c);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment