Reverse an Array (Set 4)

Easy

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

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

Example 1

reverseArrayValues()
Input
nums = [-24, 27, -3, 20, -21, -7, -36, 9, 6, 6, -22, 30, -36, 29]
Output
[29, -36, 30, -22, 6, 6, 9, -36, -7, -21, 20, -3, 27, -24]

Why

`reverseArrayValues` returns `[29, -36, 30, -22, 6, 6, 9, -36, -7, -21, 20, -3, 27, -24]` for this input.

Example 2

reverseArrayValues()
Input
nums = [7, -31, -6, -38, 3, -7, 10, -10, 27, 26, -33, -3, 40, 6, 11, 1, -11, 29, -22, -22, 7, -32, -39, 16, 15, -34, -3, 2, -14, -21, -22]
Output
[-22, -21, -14, 2, -3, -34, 15, 16, -39, -32, 7, -22, -22, 29, -11, 1, 11, 6, 40, -3, -33, 26, 27, -10, 10, -7, 3, -38, -6, -31, 7]

Why

`reverseArrayValues` returns `[-22, -21, -14, 2, -3, -34, 15, 16, -39, -32, 7, -22, -22, 29, -11, 1, 11, 6, 40, -3, -33, 26, 27, -10, 10, -7, 3, -38, -6, -31, 7]` 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.