Valid Palindrome
class Solution:
# @param {string} s A string
# @return {boolean} Whether the string is a valid palindrome
def isPalindrome(self, s):
# Write your code here
if s == '' or len(s) == 1:
return True
str = ''
for i in range(len(s)):
if s[i].isalpha() or s[i].isdigit():
str += s[i].lower()
n = len(str)
for i in range(n):
if str[i] != str[n - i - 1]:
return False
return TrueLast updated