Skip to content

Commit d5e5a44

Browse files
committed
valid-palindrome풀이
1 parent 0f3d6ac commit d5e5a44

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

valid-palindrome/socow.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
"""
2+
문제 요약
3+
- 영숫자만 고려, 대소문자 무시 → 팰린드롬 여부
4+
5+
아이디어
6+
- 소문자 변환 → 영숫자만 필터 → 역순과 동일한지 비교
7+
8+
시간복잡도: O(n)
9+
공간복잡도: O(n)
10+
"""
11+
12+
class Solution:
13+
def isPalindrome(self, s: str) -> bool:
14+
cleaned = [c for c in s.lower() if c.isalnum()]
15+
return cleaned == cleaned[::-1]

0 commit comments

Comments
 (0)