125. 验证回文串

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

解法一:

class Solution:
    def isPalindrome(self, s: str) -> bool:
        #将s过滤,只保留数字和字母,再转为小写
        s = ''.join(filter(str.isalnum, s)).lower()
        #检查对称
        return s == s[::-1]

最后更新于