My 56ms python solution


  • 0
    D
    class Solution:
    #@param{integer}x
    #@return{integer}
        def reverse(self,x):
            res=0
            flag=1
            if x<0:
                flag=-1
                x=(-1)*x
            while x>0: 
                res = res*10+x%10
                x = x/10
            if res>0x7fffffff:
                return 0
            return flag*res

Log in to reply
 

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