https://leetcode.com/problems/longest-palindrome/
class Solution: def longestPalindrome(self, s: str) -> int: ss = set() for letter in s: if letter not in ss: ss.add(letter) else: ss.remove(letter) if len(ss) != 0: return len(s) - len(ss) + 1 else: return len(s)
时间复杂度:O() 空间复杂度:O()
Last updated 8 months ago