Skip to content

Latest commit

 

History

History
32 lines (22 loc) · 459 Bytes

125.md

File metadata and controls

32 lines (22 loc) · 459 Bytes

125 Valid Palindrome

Description

link


Solution

  • code

Code

O(n)

class Solution:
    def isPalindrome(self, s):
        """
        :type s: str
        :rtype: bool
        """
        if s == "":
            return True
        
        c_list = [c.lower() for c in s if c.isalpha() or c.isdigit()]
        s = " ".join(c_list)
        return s == s[::-1]