Simple unique Method in 36ms Python


  • 0
    M
    class Solution(object):
        def reverse(self, x):
            strs=str(x)
            exp="-"
            rvrs=""
            for n in reversed((strs)):
                if not(n in exp):
                    rvrs=rvrs+n
            if abs(int(rvrs)) > 2** 31-1:
                return 0
            if(exp in strs):
                return(int(exp+rvrs))
            else:
                return(int(rvrs))
    
    
    
    
    

Log in to reply
 

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