class Solution:
"""
@param s: A string
@return: Whether the string is a valid palindrome
"""
def isPalindrome(self, s):
start, end = 0, len(s)-1
while start < end:
while start < end and not s[start].isalpha() and not s[start].isdigit():
start += 1
while start < end and not s[end].isalpha() and not s[end].isdigit():
end -= 1
if start < end and s[start].lower() != s[end].lower():
return False
start += 1
end -= 1
return True
415. Valid Palindrome
猜你喜欢
转载自blog.csdn.net/betty1121/article/details/81017657
今日推荐
周排行