# Leetcode 409. Longest Palindrome ## ASCII hashmaping solution [Leetcode offical solution](https://leetcode.cn/problems/longest-palindrome/solution/zui-chang-hui-wen-chuan-by-leetcode-solution/) ![](https://i.imgur.com/fxfMkR4.png) ```python3= class Solution: def longestPalindrome(self, s: str) -> int: ans = 0 ords = [0] * 128 for string in s: ords[ord(string)] += 1 for order in ords: ans += order // 2 * 2 if order % 2 == 1 and ans % 2 == 0: ans += 1 return an ```