You are viewing a single comment's thread. Return to all comments →
int number_needed(string a, string b) { int maxKept = 0; int answer = 0; vector<char> tempVecA(a.begin(), a.end()); vector<char> tempVecB(b.begin(), b.end()); int maxLose = (tempVecA.size()+tempVecB.size()); for(vector<char>::iterator iterA = tempVecA.begin(); iterA != tempVecA.end(); ++iterA){ for(vector<char>::iterator iterB = tempVecB.begin();iterB != tempVecB.end(); ++iterB){ if(*iterA == *iterB){ maxKept++; *iterB = 0; break; } } } answer = maxLose-2*maxKept; return answer; }
I solved mine the exact same way but using C++. I couldn't think of using ASCII either.
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 →
I solved mine the exact same way but using C++. I couldn't think of using ASCII either.