Reverse an Array (Set 5)

Easy

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

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

Example 1

reverseArrayValues()
Input
nums = [26, 36, -31, 8, 9, 17, -33, 39, 8, -19, -33, -23, 33, 2, 38, -6, 33]
Output
[33, -6, 38, 2, 33, -23, -33, -19, 8, 39, -33, 17, 9, 8, -31, 36, 26]

Why

`reverseArrayValues` returns `[33, -6, 38, 2, 33, -23, -33, -19, 8, 39, -33, 17, 9, 8, -31, 36, 26]` for this input.

Example 2

reverseArrayValues()
Input
nums = [-1, 0, 29, 39, 19, -39, 23, 13, -29, -22, 39, -35, 20, 9, -14, -3, -5, -23, 6, 38, 27, -30, 1, 24, -12, 19, 11, 11, -34, -27, 34, -2, 8, -37, -29]
Output
[-29, -37, 8, -2, 34, -27, -34, 11, 11, 19, -12, 24, 1, -30, 27, 38, 6, -23, -5, -3, -14, 9, 20, -35, 39, -22, -29, 13, 23, -39, 19, 39, 29, 0, -1]

Why

`reverseArrayValues` returns `[-29, -37, 8, -2, 34, -27, -34, 11, 11, 19, -12, 24, 1, -30, 27, 38, 6, -23, -5, -3, -14, 9, 20, -35, 39, -22, -29, 13, 23, -39, 19, 39, 29, 0, -1]` 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.