207. Reverse a Number by Recursion
Foundation1000 ms256 MBSolved by 0%
Print the digits of n in reverse order, as a number.
123 -> 321
120 -> 21
Note the second example. Reversing 120 gives 021, and as a number that is 21. Leading zeros disappear, and that is correct rather than a bug to fix.
Constraints - `0 ≤ n ≤ 1000000000`
Input
A single line containing one integer n.
Output
Print one integer, the digits of n reversed.
Input123
Output321
Noteis the plain case
Input120
Output21
Noteends in a zero, which becomes a leading zero and disappears
Hints
Four rungs, in order. The last two open once you have submitted an attempt. A wrong one counts.
Hint 1Where to start
Hint 2The approachOpen hint 1 first. This one carries on from it.
Hint 3PseudocodeOpen hint 2 first. This one carries on from it.
Hint 4Full solutionOpen hint 3 first. This one carries on from it.