int --> str --> int


  • 0
    R

    def reverse(self, x):
    """
    :type x: int
    :rtype: int
    """

        flag=0
        if x<0:
            x=-x
            flag=1
        Str=str(x)
        Str=Str[::-1]
        x=int(Str)
        if flag ==1:
            x=-x
        
        return x

Log in to reply
 

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