Reverse an Array (Set 8)

Easy

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

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

Example 1

reverseArrayValues()
Input
nums = [35, 40, -32, -15, -39, -10, -1, 34, 13, 35, -35, 26, 22, 26, -8, 1, 3, -33, 35, 10, 18, 0, 31, 26, 34, 9, 1, 12, 31]
Output
[31, 12, 1, 9, 34, 26, 31, 0, 18, 10, 35, -33, 3, 1, -8, 26, 22, 26, -35, 35, 13, 34, -1, -10, -39, -15, -32, 40, 35]

Why

`reverseArrayValues` returns `[31, 12, 1, 9, 34, 26, 31, 0, 18, 10, 35, -33, 3, 1, -8, 26, 22, 26, -35, 35, 13, 34, -1, -10, -39, -15, -32, 40, 35]` for this input.

Example 2

reverseArrayValues()
Input
nums = [-7, 20, 2, 15, -26, 12, -22, -5, 5, 9, 32, -25, 37, 0, 39, -40, -16, -12, -16, -31, -28, 1, -33, 8, -21, 6, -2, -21, 16, 0, 16, -19, -28, 10, -21, 3, 13, 3, -33]
Output
[-33, 3, 13, 3, -21, 10, -28, -19, 16, 0, 16, -21, -2, 6, -21, 8, -33, 1, -28, -31, -16, -12, -16, -40, 39, 0, 37, -25, 32, 9, 5, -5, -22, 12, -26, 15, 2, 20, -7]

Why

`reverseArrayValues` returns `[-33, 3, 13, 3, -21, 10, -28, -19, 16, 0, 16, -21, -2, 6, -21, 8, -33, 1, -28, -31, -16, -12, -16, -40, 39, 0, 37, -25, 32, 9, 5, -5, -22, 12, -26, 15, 2, 20, -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.