Skip to content

Commit 0fb50a8

Browse files
committed
valid-palindrome solution
1 parent a9df701 commit 0fb50a8

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

valid-palindrome/yyyyyyyyyKim.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Solution:
2+
def isPalindrome(self, s: str) -> bool:
3+
4+
# 소문자로 변경
5+
s = s.lower()
6+
p = ""
7+
8+
# 문자,숫자만 뽑기
9+
for i in range(len(s)):
10+
if (ord(s[i]) > 96 and ord(s[i]) < 123) or (ord(s[i]) >= 48 and ord(s[i]) <= 57):
11+
p += s[i]
12+
13+
# 문자열 뒤집기
14+
return p == p[::-1]

0 commit comments

Comments
 (0)