You are viewing a single comment's thread. Return to all comments →
My solution in c++.
int number_needed(string a, string b) { auto count = 0; vector<int> freq(26, 0); for (auto c : a) { ++freq[c - 'a']; } for (auto c : b) { --freq[c - 'a']; } for (auto val : freq) { count += abs(val); } return count; }
Seems like cookies are disabled on this browser, please enable them to open this website
Strings: Making Anagrams
You are viewing a single comment's thread. Return to all comments →
My solution in c++.