1 class Solution: 2 def longestPalindrome(self, s: str) -> int: 3 dic = {} 4 ans = bonus = 0 5 for c in s: 6 if c in dic: 7 dic[c] += 1 8 else: 9 dic[c] = 1 10 for value in dic.values(): 11 ans += value // 2 * 2 12 if value & 1 == 1:bonus = 1 13 return ans + bonus