Reverse Digits of an Integer
Return the integer whose digits are those of x in reverse order. A negative x stays negative.
Trailing zeros of x simply vanish, so 120 becomes 21.
Example 1
x 123
returns 321
321.
Example 2
x -450
returns -54
The sign stays: -54.
Constraints
-109 <= x <= 109
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.