You are viewing a single comment's thread. Return to all comments →
string gameOfThrones(string s) { const int range = 'z' - 'a' + 1; size_t pairTable[range] = {0}; for(auto & chr : s) { pairTable[chr - 'a'] ^= 1; } size_t sum = 0; for(size_t idx = 0; idx < range; idx++) { sum += pairTable[idx]; } if((s.length() % 2) == sum) { return "YES"; } return "NO"; }
Seems like cookies are disabled on this browser, please enable them to open this website
Game of Thrones - I
You are viewing a single comment's thread. Return to all comments →
string gameOfThrones(string s) { const int range = 'z' - 'a' + 1; size_t pairTable[range] = {0}; for(auto & chr : s) { pairTable[chr - 'a'] ^= 1; } size_t sum = 0; for(size_t idx = 0; idx < range; idx++) { sum += pairTable[idx]; } if((s.length() % 2) == sum) { return "YES"; } return "NO"; }