Reverse Number - III
Given a non-negative integer N, return the number obtained by reversing the digits of N using recursion.
Note:
- If N ends with one or more zeros, they do not appear at the beginning of the reversed result because leading zeros are ignored.
- A normal iterative solution will pass the test cases, but the goal is to solve this problem using recursion and strengthen your understanding of recursive calls and base cases.
Example 1:
Input: N = 421
Output: 124
Explanation: Reversing the digits of 421 gives 124.
Example 2:
Input: N = 100
Output: 1
Explanation: Reversing 100 gives 001, which is represented as 1 after leading zeros are ignored.
Now Your Turn!
Pick the correct output for the given inputInput: N = 405
Still unsure what the problem is asking ?
Let’s go through a few more examples, step by step, to make it clearer.
Constraints:
- 0 <= N <= 109