classSolution: """ @param s: A string @return: Whether the string is a valid palindrome """ defisPalindrome(self, s): # edge condition if s == "": returnTrue # pre-process real = [ch.lower() for ch in s if ch.isalnum()] # solve i = 0 j = len(real) - 1 while i <= j: if real[i] != real[j]: returnFalse i += 1 j -= 1 returnTrue