Game of Thrones - I

  • + 0 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"; }