reverse solution in Python3


  • 2
    L

    '''
    class Solution:
    def reverse(self, x):
    s = (x > 0) - (x < 0) #check if the number is positive or negative
    r = int(str(sx)[::-1]) #slicing the number, making it absolute and reversing it
    return r
    s*(r < 2**31 - 1) #checking for overflow
    '''


  • 0
    S

    What does sx & rs imply here?


  • 0
    L

    @SSN002 i put the ˋ*´ mark i dont know why it didnt show! Its multiplication between the two variables. sx = s * x and rs=r * s


Log in to reply
 

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