[
palindrome
string
counter
hash table
]
Leetcode 0266. Palindrome Permutation
Problem statement
https://leetcode.com/problems/palindrome-permutation/
Solution
Just check that all frequencies except may be one are even.
Complexity
Time complexity is $O(n)$, space complexity is $O(m)$, where $m$ is the size of alphabet.
Code
class Solution:
def canPermutePalindrome(self, s):
return sum(b%2 == 1 for a,b in Counter(s).items()) < 2