65ms using python filter on string

  • 2

    A lot of times using Python feels like cheating when doing leetcode...
    Slicing. Lambda. Cool builtin functions.

    def isPalindrome(self, s):
            new_s = filter(lambda x: x.isalnum(), s).lower()
            return new_s == new_s[::-1]

Log in to reply

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