We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 63dac45 commit a9af198Copy full SHA for a9af198
valid-palindrome/EstherKim97.py
@@ -0,0 +1,11 @@
1
+class Solution(object):
2
+ def isPalindrome(self, s):
3
+ import re
4
+ # remove all non-alphanumeric characters
5
+ s = re.sub(r'\W+', '', s.lower())
6
+
7
+ # check if the string is equal forward and backward
8
+ for i in range(len(s)//2):
9
+ if s[i] != s[-(i+1)]:
10
+ return False
11
+ return True
0 commit comments