python


  • 0
    B

    '''
    class Solution:
    def reverse(self, x):
    """
    :type x: int
    :rtype: int
    """
    if x>0:
    str_x0=str(x)
    str_x1=str_x0[::-1]
    elif x==0:
    return 0
    else:
    str_x0=str(x)
    str_x1='-'+str_x0[:0:-1]

        if int(str_x1)>=2**31-1 or int(str_x1)<=-2**31:
            return 0
        else:         
            return int(str_x1)
    

    '''


Log in to reply
 

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