You are viewing a single comment's thread. Return to all comments →
int makingAnagrams(string s1, string s2) { int arr[26] = {0}; for(int i = 0 ; i < s1.size(); i++) { arr[s1[i] - 'a']++; }
for(int i = 0 ; i < s2.size(); i++) { arr[s2[i] - 'a']--; } int count = 0; for(int i = 0; i < 26; i++) { if(arr[i] > 0) { count = count + arr[i]; } else if(arr[i] < 0) { count = count + abs(arr[i]); } } return count;
}
return 0;
Seems like cookies are disabled on this browser, please enable them to open this website
Making Anagrams
You are viewing a single comment's thread. Return to all comments →
int makingAnagrams(string s1, string s2) { int arr[26] = {0}; for(int i = 0 ; i < s1.size(); i++) { arr[s1[i] - 'a']++; }
}
}