Reverse int without converting to string


  • 0
    B

    inversion logic (excluding validations per requirements):

       finalX = modVal = 0
        while x>0:
            modVal = x%10
            x = x/10
            finalX = finalX * 10 + modVal

Log in to reply
 

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