이직하고만다(분노)
99클럽 코테 스터디 38일차 TIL + 리트코드 그리디
xxo_ohii
2024. 8. 29. 09:36
728x90
- 주제 : 그리디
- 링크 : https://leetcode.com/problems/longest-palindrome/
from collections import Counter
class Solution:
def longestPalindrome(self, s: str) -> int:
counts = Counter(s)
length = 0
odd_found = False
for count in counts.values():
if count % 2 == 0:
length += count
else:
length += count - 1
odd_found = True
if odd_found:
length += 1
return length
알고리즘 강의를 들어야할까....
일단 문제인거.
그리디, 그래프, dfs, bfs, 스택, 큐, 완전탐색
ㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋ
다문제다
728x90