Valid Palindrome
Input:
"A man, a plan, a canal: Panama"
Output:
trueInput:
"race a car"
Output:
falseclass Solution:
def isPalindrome(self, s):
"""
:type s: str
:rtype: bool
"""
s = [c.lower() for c in s if c.isalnum()]
start, end = 0, len(s) - 1
while start < end:
if s[start] != s[end]:
return False
start += 1
end -= 1
return TrueLast updated