We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Algorithms
- Strings
- Game of Thrones - I
- Discussions
Game of Thrones - I
Game of Thrones - I
Sort by
recency
|
1074 Discussions
|
Please Login in order to post a comment
Here is my c++ solution : explanation here : https://youtu.be/yhSaL48IHds
solution 1 :
solution 2 :
One liner.
def gameOfThrones(s):
return "NO" if sum([1 for i in [s.count(i) for i in set(s)] if i % 2 != 0]) > 1 else "YES"
Python 3
for Python3 Platform
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"; }