Codeforces Round #436 (Div. 2), problem: (B) Polycarp and Letters Solution In C/C++

#include <stdio.h>

int c[26];

void reset(){
for(int i=0;i<26;i++){
c[i]=0;
}
}

int main(){
int n,i,cur=0,max=0;
scanf(“%d”,&n);
char a[n+1];
scanf(“%s”,a);

reset();
for(i=0;i<n;i++){
if(a[i]>=’A’ && a[i]<=’Z’){
cur=0;
reset();
}
else if(c[a[i]-‘a’]==0){
c[a[i]-‘a’]++;
cur++;
}
if(cur>max){
max=cur;
}
}
printf(“%d\n”,max);
return 0;
}

(Visited 90 times, 1 visits today)

About the Author:

Leave A Comment