Skip to content

Commit 4b09054

Browse files
committed
validate palindrome solution
1 parent 8b4a01f commit 4b09054

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

valid-palindrome/yuseok89.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# TC: O(N)
2+
# SC: O(1)
3+
class Solution:
4+
def isPalindrome(self, s: str) -> bool:
5+
6+
import re
7+
8+
s = re.sub(r'[^a-zA-Z0-9]', '', s.lower())
9+
10+
n = len(s)
11+
12+
for idx in range(0, n // 2):
13+
if s[idx] != s[n - idx - 1]:
14+
return False
15+
16+
return True
17+

0 commit comments

Comments
 (0)