Accepted python solution

  • 1
    class Solution(object):
        def isPalindrome(self, s):
            :type s: str
            :rtype: bool
            stripped_string = ''.join(ch for ch in s if ch.isalnum()).strip(' ').lower()
            reversed_string = stripped_string[::-1]
            if len(stripped_string) == 1 or len(stripped_string) == 0 or len(s)==1 or len(s)==0:
                return True
            if stripped_string == reversed_string:
                return True
            return False

Log in to reply

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