Solution in Python

  • 0

    class Solution(object):
    def reverse(self, x):
    :type x: int
    :rtype: int
    rev = int(str(abs(x))[::-1])
    if abs(x) > pow(2, 31) or abs(rev) > pow(2, 31):
    return 0
    return rev if x > 0 else -rev

Log in to reply

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