Simple Python Solution with [::-1]


  • 2
    S

    class Solution(object):
    def isPalindrome(self, x):
    """
    :type x: int
    :rtype: bool
    """

        if x < 0:
            return False
        else:
            return x == int(str(x)[::-1])

  • 2
    L

    Still use extra space, though not exposed to user


Log in to reply
 

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