This is a pretty easy one, finding a valid palindrome.
Here's my solution to the problem.
class Solution:
def isPalindrome(self, s: str) -> bool:
s = s.lower()
new_s = ''
for char in s:
if char.isalnum():
new_s += char
if new_s == new_s[::-1]:
return True
else:
return False
The time and space complexity is O(N)
Top comments (0)