You are viewing a single comment's thread. Return to all comments →
If there is more than 1 letter that occurs odd number of times then there is no anagram.
int main(){ char *s = (char*)malloc(100001); scanf("%s",s); int arr[26] = {0}; int l = strlen(s); for(int i = 0; i < l; i++){ arr[s[i]-97]++; } int countOdd = 0; for(int i = 0; i < 26; i++){ if(arr[i] % 2 == 1) countOdd++; if(countOdd > 1){ printf("NO"); break; } if(i == 25) printf("YES"); } return 0; }
Seems like cookies are disabled on this browser, please enable them to open this website
Game of Thrones - I
You are viewing a single comment's thread. Return to all comments →
If there is more than 1 letter that occurs odd number of times then there is no anagram.