Skip to content

Commit f65a8cc

Browse files
committed
valid-palindrome solution
1 parent 9a56411 commit f65a8cc

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

valid-palindrome/TreeStone94.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
class Solution:
2+
def isPalindrome(self, s: str) -> bool:
3+
answer = ""
4+
for c in s:
5+
o = ord(c)
6+
if 65 <= o <=90:
7+
answer += chr(o+32)
8+
elif 97 <= o <= 122:
9+
answer += c
10+
elif 48 <= o <= 57:
11+
answer += c
12+
13+
if answer == "" or answer == answer[::-1]:
14+
return True
15+
else:
16+
return False
17+
18+

0 commit comments

Comments
 (0)