Question: The template code below is supposed to return a new array, where the resulting array contains the elements in original, but reversed. The following examples
The template code below is supposed to return a new array, where the resulting array contains the elements in original, but reversed. The following examples illustrate this behavior:
-
reverseArray(new int[]{})returnsnew int[]{} -
reverseArray(new int[]{1})returnsnew int[]{1} -
reverseArray(new int[]{1, 2})returnsnew int[]{2, 1} -
reverseArray(new int[]{1, 2, 3})returnsnew int[]{3, 2, 1}
The signature of reverseArray has been provided below. Finish implementing the reverseArray method.
public static int[] reverseArray(int[] original) { ... }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
