Solution in Python3


  • 0
    G

    This seems to work fine. Passed all tests with a runtime of 64ms:

    class Solution:
        def reverse(self,x):
    	    rev=int(str(abs(x))[::-1])
    	    if rev>(2**32/2) or x==0 or rev<-2**32/2:
    		    return 0
    	    else:
    		    return x//abs(x)*rev
    

Log in to reply
 

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