You are viewing a single comment's thread. Return to all comments →
//check_anagram optimised.
int check_anagram(char a[], char b[]) { int first[26] = {0}; if(strlen(a)) != strlen(b)) return 0; while (a[c] != '\0') { first[a[c]-'a']++; first[b[c]-'a']--; } for (c = 0; c < 26; c++) { if (first[c]>0 || first[c]<0) return 0; return 1; }
Sherlock and Anagrams
You are viewing a single comment's thread. Return to all comments →
//check_anagram optimised.