As Pythonic As You Can Get


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

Log in to reply
 

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