Skip to content

Commit eb99bb3

Browse files
committed
125. 验证回文串
1 parent 4a448cf commit eb99bb3

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

str/125_isPalindrome.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Solution:
2+
def isPalindrome(self, s: str) -> bool:
3+
if not s:
4+
return True
5+
l = list()
6+
for c in s.upper():
7+
if c.isdigit() or c.isalpha():
8+
l.append(c)
9+
if not l:
10+
return True
11+
print(l)
12+
return l == l[::-1]

0 commit comments

Comments
 (0)