Skip to content

Commit d4394bd

Browse files
committed
[WHYjun] WEEK 03 solutions - (1/5)
1 parent 1f31fbe commit d4394bd

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

valid-palindrome/WHYjun.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+
s = [c.lower() for c in s if c.isalnum()]
4+
5+
if len(s) == 1:
6+
return True
7+
8+
l, r = 0, len(s) - 1
9+
while l < r:
10+
if s[l] != s[r]:
11+
return False
12+
l += 1
13+
r -= 1
14+
return True

0 commit comments

Comments
 (0)