Golang | Leetcode Golang题解之第409题最长回文串
题目:
题解:
func longestPalindrome(s string) int {mp := map[byte]int{}for i := 0; i < len(s); i++ {mp[s[i]]++}res := 0for _, v := range mp {if v&1 == 1 {res += v - 1} else {res += v}}if res<len(s) {res++}return res
}