Solution in Python


  • 0
    G

    class Solution(object):
    def reverse(self, x):
    """
    :type x: int
    :rtype: int
    """
    result = int(str(x)[::-1]) if x>=0 else -1 * int(str(x)[1:][::-1])
    return result if -2 ** 31<=result<=2 ** 31-1 else 0


Log in to reply
 

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