Python: Naive


  • 0
    import string
    
    class Solution(object):
        def isPalindrome(self, s):
            exclude = set(string.punctuation + " ")
            s = "".join(ch for ch in s if ch not in exclude).lower()
            return s == s[::-1]
    

Log in to reply
 

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