You are viewing a single comment's thread. Return to all comments →
Similar approach using accumulate with a lambda instead
int makeAnagram(string a, string b) { vector<int>v(26,0); for(auto& c : a){ v[c -'a']++; } for(auto& c : b){ v[c -'a']--; } return accumulate(v.begin(), v.end(), 0, [](int x, int y) { return abs(x) + abs(y);}); }
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 →
Similar approach using accumulate with a lambda instead