class Solution:
def longestPalindrome(self, s: str) -> int:
r, pool = 0, set()
for c in s:
if c in pool:
pool.remove(c)
r += 1
else:
pool.add(c)
return r * 2 + bool(pool)
409. Longest Palindrome - LeetCode
ยท One min read