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
'이직하고만다(분노)' 카테고리의 다른 글
99클럽 코테 스터디 41일차 TIL + 리트코드 DP (0) | 2024.08.31 |
---|---|
99클럽 코테 스터디 39일차 TIL + 리트코드 탐욕법 (0) | 2024.08.30 |
99클럽 코테 스터디 37일차 TIL + 백준 완전탐색 (0) | 2024.08.28 |
99클럽 코테 스터디 36일차 TIL + 백준 완전탐색(브1) (5) | 2024.08.27 |
99클럽 코테 스터디 35일차 TIL + 백준 깊이너비탐색(실버1) (1) | 2024.08.26 |