FunctionRacerProblemsRace

Reverse Digits of an Integer

EasyMathPython, JavaScript, TypeScript, Java, C++

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

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Math problems