You are viewing a single comment's thread. Return to all comments →
Solution that does not need the third loop
int makeAnagram(string a, string b) { array<int, 256> hash{0}; int remove = 0; for (auto c: a) ++hash[c], ++remove; for (auto c: b) if (hash[c] > 0) --remove, --hash[c]; else ++remove; return remove; }
Strings: Making Anagrams
You are viewing a single comment's thread. Return to all comments →
Solution that does not need the third loop