My 60ms python solution


  • 0
    B
    class Solution(object):
        def reverse(self, x):
            """
            :type x: int
            :rtype: int
            """
            _str = str(x)[::-1]
            if x < 0:
                _str = '-' + _str[:-1]
            ret = int(_str)
            if ret > 2**31 or ret <= -2**31:
                return 0
            else:
                return ret

Log in to reply
 

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