My simple python solution from an new point of view


  • 2
    G
    enter code hereclass Solution(object):
    def reverse(self, x):
        """
        :type x: int
        :rtype: int
        """
        res=int(str(abs(x))[::-1])
    
        if len(bin(res)[2:])>=32:
            return 0
        else:
            if x>=0:
                return res
            else:
                return -res

Log in to reply
 

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