728x90
반응형
Python
class Solution:
def longestPalindrome(self, s: str) -> int:
s_set = set(list(s))
count = 0
count_solo = False
for ch in s_set:
ch_count = s.count(ch) // 2
count += ch_count * 2
if s.count(ch) % 2 != 0:
count_solo = True
if count_solo:
count += 1
return count
728x90
반응형
'LeetCode > Easy' 카테고리의 다른 글
104. Maximum Depth of Binary Tree (0) | 2022.05.07 |
---|---|
455. Assign Cookies (0) | 2022.04.19 |
509. Fibonacci Number (0) | 2022.04.09 |
58. Length of Last Word (0) | 2022.04.08 |
101. Symmetric Tree (0) | 2022.04.06 |