← Unit 2 · all exercises
Saved in this browser only

Reverse the digits

Return the number with its digits reversed. 1234 becomes 4321.

int reverse(int n)

Solution.java
Loading editor…
Results

Examples

  • reverse(1234) → 4321
  • reverse(7) → 7

There are also 4 hidden tests you can't see. Solve the problem, not the examples.