You are viewing a single comment's thread. Return to all comments →
C++ Solution
int makeAnagram(string a, string b) { string anagram; for (int i = 0; i < a.length(); i++) { int bCharCount = (int)count(b.begin(), b.end(), a.at(i)); int anagramCount = (int)count(anagram.begin(), anagram.end(), a.at(i)); if ((b.find(a[i]) != string::npos)) { if (anagramCount < bCharCount) anagram += a[i]; } } return (a.length() + b.length()) - (anagram.length() * 2); }
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 →
C++ Solution