52 ms, 99.84%, regex with Python

  • 0

    This is how my script worked:

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

Log in to reply

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