Reverse Number

Given a non-negative integer n, return the integer formed by reversing its decimal digits. Leading zeroes in the reversed representation are discarded…

Given a non-negative integer `n`, return the integer formed by reversing its decimal digits. Leading zeroes in the reversed representation are discarded automatically; for example, `1200` becomes `21`.

- `0 <= n <= 10^9` - The reversed result fits in a signed 32-bit integer.

Example 1: input n = 1234; output 4321. Reading the digits in reverse order gives 4321.

Example 2: input n = 1200; output 21. Reversal gives 0021, whose integer value is 21.

Example 3: input n = 0; output 0. Reversing the single digit zero still gives zero.

Category: Math. Topic: math. Difficulty: Easy. Patterns: math.