Reverse an Array (Set 7)

Easy

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

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

Example 1

reverseArrayValues()
Input
nums = [12, -20, 12, -32, 11, -18, 13, -11, -30, 37, -29, 17, -20, -29, -20, 34, 7, 28, -6, 8, -35, -8, 7, 4, -30, 28, -4, -6, -17, 5, -2, 30, 26, 20, -6]
Output
[-6, 20, 26, 30, -2, 5, -17, -6, -4, 28, -30, 4, 7, -8, -35, 8, -6, 28, 7, 34, -20, -29, -20, 17, -29, 37, -30, -11, 13, -18, 11, -32, 12, -20, 12]

Why

`reverseArrayValues` returns `[-6, 20, 26, 30, -2, 5, -17, -6, -4, 28, -30, 4, 7, -8, -35, 8, -6, 28, 7, 34, -20, -29, -20, 17, -29, 37, -30, -11, 13, -18, 11, -32, 12, -20, 12]` for this input.

Example 2

reverseArrayValues()
Input
nums = [-3, -20, 4, 11, -18, 24, -34, 10, 11, 25, -17, 26, -9, 0, -9, -33, -24, -1, 36, 12, 29, 34, -22, -39, 22, -19, 38, -2, 21, -7, -10, -27, -4, 19, 32, -7, -20, 6]
Output
[6, -20, -7, 32, 19, -4, -27, -10, -7, 21, -2, 38, -19, 22, -39, -22, 34, 29, 12, 36, -1, -24, -33, -9, 0, -9, 26, -17, 25, 11, 10, -34, 24, -18, 11, 4, -20, -3]

Why

`reverseArrayValues` returns `[6, -20, -7, 32, 19, -4, -27, -10, -7, 21, -2, 38, -19, 22, -39, -22, 34, 29, 12, 36, -1, -24, -33, -9, 0, -9, 26, -17, 25, 11, 10, -34, 24, -18, 11, 4, -20, -3]` 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.