Formatted question description: https://leetcode.ca/all/266.html
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. Hint: Consider the palindromes of odd vs even length. What difference do you notice? Count the frequency of each character. If each character occurs even number of times, then it must be a palindrome. How about character which occurs odd number of times?
Use HashSet to traverse the string
- If a letter is not in the HashSet, we add this letter,
- If the letter already exists, we delete the letter, So in the end, if there are no letters or only one letter in the HashSet, it means that it is a palindrome.