← Unit 4 · all exercises
Saved in this browser only

Reverse an array

Return a new array holding the same numbers in the opposite order. Leave the original untouched.

int[] reversed(int[] values)

Solution.java
Loading editor…
Results

Examples

  • java.util.Arrays.toString(Solution.reversed(new int[]{1, 2, 3})) → [3, 2, 1]
  • java.util.Arrays.toString(Solution.reversed(new int[]{7})) → [7]

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