Reverse an Array (Set 10)

Easy

Given an array of integers nums, return a new array with the same values in reverse order.

Reverse an Array (Set 10) — the data. This set runs 4 cases: nums holds arrays of 37–48 items, with values from -40 to 39. The hidden cases are the largest of the set.

Example 1

reverseArrayValues()
Input
nums = [-34, -24, 25, 36, 36, 30, 26, -34, 23, -28, -28, -27, 15, -17, -3, -23, -20, 31, -3, 7, -31, -2, -34, 37, -6, -13, -2, 9, -4, 15, -14, -4, -26, 36, -8, 12, -25]
Output
[-25, 12, -8, 36, -26, -4, -14, 15, -4, 9, -2, -13, -6, 37, -34, -2, -31, 7, -3, 31, -20, -23, -3, -17, 15, -27, -28, -28, 23, -34, 26, 30, 36, 36, 25, -24, -34]

Why

`reverseArrayValues` returns `[-25, 12, -8, 36, -26, -4, -14, 15, -4, 9, -2, -13, -6, 37, -34, -2, -31, 7, -3, 31, -20, -23, -3, -17, 15, -27, -28, -28, 23, -34, 26, 30, 36, 36, 25, -24, -34]` for this input.

Example 2

reverseArrayValues()
Input
nums = [2, -39, 28, 10, -34, 12, -20, -38, -9, -3, 30, -22, 21, -12, 31, 17, 30, -17, -11, -18, 39, 32, -24, -15, 17, 20, -4, -30, 11, -11, 36, 37, 1, 8, 34, -32, -6, 1, -24, 9, 1, -9, 21, 11, -7, 26, 26, -9]
Output
[-9, 26, 26, -7, 11, 21, -9, 1, 9, -24, 1, -6, -32, 34, 8, 1, 37, 36, -11, 11, -30, -4, 20, 17, -15, -24, 32, 39, -18, -11, -17, 30, 17, 31, -12, 21, -22, 30, -3, -9, -38, -20, 12, -34, 10, 28, -39, 2]

Why

`reverseArrayValues` returns `[-9, 26, 26, -7, 11, 21, -9, 1, 9, -24, 1, -6, -32, 34, 8, 1, 37, 36, -11, 11, -30, -4, 20, 17, -15, -24, 32, 39, -18, -11, -17, 30, 17, 31, -12, 21, -22, 30, -3, -9, -38, -20, 12, -34, 10, 28, -39, 2]` for this input.
Constraints
0 <= nums.length <= 10^5
-10^4 <= nums[i] <= 10^4
Every case in this set must pass: the first two are visible on Run, the last two unlock on Submit.

Topics

ArraysTwo Pointers

Implement reverseArrayValues in the editor and return the answer — printing it is never graded.