125. Valid Palindrome

https://leetcode.com/problems/valid-palindrome/

solution

class Solution:
    def isPalindrome(self, s: str) -> bool:
        s = s.lower()
        s = [i for i in s if i.isalnum()]  # isdigit, isalpha, isalnum(alphanumeric)
        return s[::-1] == s

时间复杂度:O() 空间复杂度:O()

follow up

回文类

Last updated