You are viewing a single comment's thread. Return to all comments →
I made a similar answer in C++, using unordered_map.
int makingAnagrams(const string &s1, const string &s2){ unordered_map<char, int> letters; for(char c: s1){ ++letters[c]; } for(char c: s2){ --letters[c]; } int countDeletions = 0; for(pair<char, int> pr: letters){ if (pr.second != 0){ countDeletions += abs(pr.second); } } return countDeletions; }
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 →
I made a similar answer in C++, using unordered_map.