Reverse an Array (Set 9)

Easy

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

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

Example 1

reverseArrayValues()
Input
nums = [25, -4, -9, -30, -23, -25, -6, -20, -28, -6, 31, 19, -20, 25, 37, 40, 15, 19, 27, 20, -3, -1, -23, 27, 22, -12, -38, 18, -1, 31, 12, 8, -29]
Output
[-29, 8, 12, 31, -1, 18, -38, -12, 22, 27, -23, -1, -3, 20, 27, 19, 15, 40, 37, 25, -20, 19, 31, -6, -28, -20, -6, -25, -23, -30, -9, -4, 25]

Why

`reverseArrayValues` returns `[-29, 8, 12, 31, -1, 18, -38, -12, 22, 27, -23, -1, -3, 20, 27, 19, 15, 40, 37, 25, -20, 19, 31, -6, -28, -20, -6, -25, -23, -30, -9, -4, 25]` for this input.

Example 2

reverseArrayValues()
Input
nums = [-39, 24, -20, 24, 12, 29, 22, -10, -12, 31, 23, 33, -35, -33, 0, 13, 20, -23, -3, 4, -4, -27, -28, 9, 18, 4, 11, 28, 0, 27, 24, 2, -32, 35, -10, 6, -5, 2, 16, -34, -34, -20, -39, 26, 25, 1, 33]
Output
[33, 1, 25, 26, -39, -20, -34, -34, 16, 2, -5, 6, -10, 35, -32, 2, 24, 27, 0, 28, 11, 4, 18, 9, -28, -27, -4, 4, -3, -23, 20, 13, 0, -33, -35, 33, 23, 31, -12, -10, 22, 29, 12, 24, -20, 24, -39]

Why

`reverseArrayValues` returns `[33, 1, 25, 26, -39, -20, -34, -34, 16, 2, -5, 6, -10, 35, -32, 2, 24, 27, 0, 28, 11, 4, 18, 9, -28, -27, -4, 4, -3, -23, 20, 13, 0, -33, -35, 33, 23, 31, -12, -10, 22, 29, 12, 24, -20, 24, -39]` 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.