longest common pattern : giving wrong answer

#include<stdio.h>
inline void eval(char a[]){
register char c=’\0’;
while(c<‘A’)
c=getchar_unlocked();
while(c>=‘A’){
a[c-‘A’]++;
c = getchar_unlocked();
}
}
int main(){
int z,i,ans=0;
char a[60]={’\0’},b[60]={’\0’};
scanf("%d",&z);
while(z–){
eval(a);
eval(b);
for(i=0;i<60;i++){
ans+= (a[i]<b[i]?a[i]:b[i]);
a[i]=b[i]=’\0’;
}
printf("%d\n",ans);
ans=0;
}
return 0;
}

I could not get the above one so, I have debugged your last but one submission (ID : 4369074).In that You have made a silly mistake by declaring b[] as char instead of int. So Try changing char to int, it will work.And HERE is your accepted solution.Sorry for the wrong ID given above(4369074). And still If you have any doubt’s comment below.

2 Likes
//