Reverse an Array (Set 3)

Easy

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

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

Example 1

reverseArrayValues()
Input
nums = [17, 10, 2, -33, -21, 24, 15, -17, -14, 34, 10, -26, 28, 19, -13, 21, 2]
Output
[2, 21, -13, 19, 28, -26, 10, 34, -14, -17, 15, 24, -21, -33, 2, 10, 17]

Why

`reverseArrayValues` returns `[2, 21, -13, 19, 28, -26, 10, 34, -14, -17, 15, 24, -21, -33, 2, 10, 17]` for this input.

Example 2

reverseArrayValues()
Input
nums = [29, -30, -16, -13, -10, 8, -36, 5, 22, 2, -10, 7, -24, -19, -2, -8, 23, -20, -31, 40, -18, 29]
Output
[29, -18, 40, -31, -20, 23, -8, -2, -19, -24, 7, -10, 2, 22, 5, -36, 8, -10, -13, -16, -30, 29]

Why

`reverseArrayValues` returns `[29, -18, 40, -31, -20, 23, -8, -2, -19, -24, 7, -10, 2, 22, 5, -36, 8, -10, -13, -16, -30, 29]` 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.