2 line Python Regular Expression Answer (beats 99%)


  • 0
    W
    import re
    class Solution(object):
        def isPalindrome(self, s):
            fixed_str = re.sub(r'\W', '', str.lower(str(s)))
            return fixed_str == fixed_str[::-1]
    

Log in to reply
 

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