class Solution(object):
def canPermutePalindrome(self, s):
"""
:type s: str
:rtype: bool
"""
counter = collections.defaultdict(int)
for c in s:
counter[c] += 1
return len([counter[c] for c in counter if counter[c] % 2 != 0]) <= 1
class Solution {
public:
bool canPermutePalindrome(string s) {
bitset<256> count;
for (char c : s) {
count.flip(c);
}
int odd = 0;
for (int i = 0; i < 256; ++i) {
if (count[i]) {
if (++odd > 1) return false;
}
}
return true;
}
};