You are viewing a single comment's thread. Return to all comments →
Using parity bits in a single integer was a fun way to do this in C++. Here a 0 bit is even, a 1 bit is odd.
int main() { string s; cin >> s; int parity = 0; for (char ch : s) parity ^= 1 << (ch - 'a'); cout << (__builtin_popcount(parity) <= 1 ? "YES" : "NO") << endl; return 0; }
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 →
Using parity bits in a single integer was a fun way to do this in C++. Here a 0 bit is even, a 1 bit is odd.