Leetcode - Palindrome Permutation
https://leetcode.com/problems/palindrome-permutation/
Given a string, determine if a permutation of the string could form a palindrome.
Example 1:
Input: "code"
Output: false
Example 2:
Input: "aab"
Output: true
Example 3:
Input: "carerac"
Output: true
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | func canPermutePalindrome(s string) bool { hash := map[byte] int {} for i := 0; i < len(s); i++ { hash[s[i]]++ } oddCount := 0 for _, val := range hash { if val % 2 == 1 { oddCount++ } } if oddCount > 1{ return false } return true } |