You are viewing a single comment's thread. Return to all comments →
C++
int anagram(string s) { if(s.size() % 2 == 1) return -1; int HalfSize = s.size() / 2; int count = 0; for (int i = 0; i < HalfSize; i++) { bool isFound = false; for (int j = HalfSize; j < s.size(); j++) { if(s[i] == s[j]) { s[j] = ' '; isFound = true; break; } } if (!isFound) count++; } return count; }
Seems like cookies are disabled on this browser, please enable them to open this website
Anagram
You are viewing a single comment's thread. Return to all comments →
C++