(Python) Simple regex solution 56ms


  • 0
    D
    import re
    class Solution(object):
        def isPalindrome(self, s):
            """
            :type s: str
            :rtype: bool
            """
            s=s.lower()
            s=re.sub(r'[^a-z0-9]','',s)
            if s==s[::-1]:
                return True
            else:
                return False
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.