266_Palindrome Permutation
Given a string, determine if a permutation of the string could form a palindrome.
For example,
"code"
-> False,"aab"
-> True,"carerac"
-> True.
Solution
In order to be palindrome after permutation, the number of characters with odd number of occurences can't exceed 1(1 in case of odd length and 0 in case of even length)
Count the frequency of each letter, stored in a dictionary
Check if more than one frequency is odd
Time: O(n)
Space: O(1)
Last updated