5 Lines, Top 7% Python Submission


  • 0
    _

    Very short Python submission with a few tricks, top 7% runtime.

    Hopefully self-explanatory.

    class Solution(object):
        def isPalindrome(self, x):
            """
            :type x: int
            :rtype: bool
            """
            x = str(x)
            if x == x[::-1]:
                return True
            else:
                return False
    

Log in to reply
 

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