You are viewing a single comment's thread. Return to all comments →
I use only one container to store the letters instead 2 containers.
And I reach the solution without check the discussion forum.
More differences:
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){ countDeletions += abs(pr.second); } return countDeletions; }
This solution is very elegant. :-)
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 use only one container to store the letters instead 2 containers.
And I reach the solution without check the discussion forum.
More differences:
This solution is very elegant. :-)