Python solution beating 99%


  • 0
    A
    class Solution(object):
        def isPalindrome(self, s):
            orderedString = s
            orderedString = ''.join(str(orderedString).translate(None, string.punctuation).lower().split())
            reversedString = orderedString[::-1]
            return orderedString == reversedString
    

    Simply reverse the string and compare them


Log in to reply
 

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