Problem statement : STONES Problem - CodeChef
My code is:
#include <string.h>
#define MAX 101
int j[26*2];
int s[26*2];
int main(void) {
int t, i;
scanf("%d", &t);
while(t--){
char stone[MAX], jewel[MAX];
scanf("%s", jewel); scanf("%s", stone);
for(i = 0; i < 26*2; i++){
j[i] = 0; s[i] = 0;
}
for(i = 0; i < strlen(jewel); i++){
if(jewel[i] <= 'Z')
j[jewel[i] - 'A'] = 1;
else
j[jewel[i] - 'a' + 26] = 1;
}
for(i = 0; i < strlen(stone); i++){
if(stone[i] <= 'Z')
s[stone[i] - 'A'] = 1;
else
s[stone[i] - 'a' + 26] = 1;
}
int count = 0;
for(i = 0; i < 26*2; i++){
if(s[i] && j[i])
++count;
}
printf("%d\n", count);
}
return 0;
}
I cant figure out what’s wrong in this simple code. Thanks.