Skip to content

Commit e833027

Browse files
committed
valid palindrome solution
1 parent 0b0a799 commit e833027

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

valid-palindrome/yayyz.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Solution:
2+
def isPalindrome(self, s: str) -> bool:
3+
s = ''.join(filter(str.isalnum, s)).lower()
4+
if not (s and s.strip()): return True
5+
6+
head = 0
7+
tail = len(s) -1
8+
while head < tail:
9+
if s[head] != s[tail]:
10+
return False
11+
else:
12+
head += 1
13+
tail -= 1
14+
15+
return True

0 commit comments

Comments
 (0)