13. Reverse Array

Given an integer array arr. Write a function int[] ReverseArray(int[] arr) that returns a new array with elements in reverse order.
Example 1
Input: arr = [1, 2]
Output: [2, 1]
Explanation: The two elements are swapped
Example 2
Input: arr = [1, 2, 3]
Output: [3, 2, 1]
Explanation: The array elements are placed in reverse order
Example 3
Input: arr = [5]
Output: [5]
Explanation: A single-element array remains unchanged
arrayseasy
JavaScript
Loading...
Line 1, Char 1