Skip to content

Instantly share code, notes, and snippets.

@kartikmaji
Created September 30, 2014 13:57
Show Gist options
  • Select an option

  • Save kartikmaji/a25615e0c4e8b82c88c1 to your computer and use it in GitHub Desktop.

Select an option

Save kartikmaji/a25615e0c4e8b82c88c1 to your computer and use it in GitHub Desktop.
#include<stdio.h>
#include<string.h>
int main()
{
char s[10000];
int a[26]={0};
int i;
int count=1;
scanf("%s",s);
for(i=0;i<strlen(s);i++)
{
if(s[i]==s[i+1])
{
count++;
}
if(count>a[s[i]-97])
{
a[s[i]-97]=count;
}
else
{
count=1;
}
}
int max;
count=0;
max=a[0];
for(i=0;i<26;i++)
{
if(max<a[i])
{
count=i;
max=a[i];
}
}
printf("%c\n",count+97);
printf("%d\n",max);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment