Skip to content

Commit 432fda4

Browse files
committed
valid palindrome solution
1 parent bc68cb3 commit 432fda4

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# isalnum() : ๋ฌธ์ž์—ด์ด ์˜์–ด, ํ•œ๊ธ€ ์ˆซ์ž -> True , ์•„๋‹ˆ๋ผ๋ฉด False
2+
class Solution:
3+
def isPalindrome(self, s: str) -> bool:
4+
s = s.replace(" ", "")
5+
changed_s = [c.lower() for c in s if c.isalnum()]
6+
return changed_s == changed_s[::-1]

0 commit comments

Comments
ย (0)