Reverse an Array (Set 11)

Easy

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

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

Example 1

reverseArrayValues()
Input
nums = [-19, -5, -11, -29, 32, -35, 21, 25, -20, -30, -14, -8, -27, 6, 26, 39, 10, 17, -34, 38, -10, 31, 9, 2, 28, -32, 4, -15, 13, 33, 24, -37, 12, 0, -34, 28, 18, 16, -22, -13, 5]
Output
[5, -13, -22, 16, 18, 28, -34, 0, 12, -37, 24, 33, 13, -15, 4, -32, 28, 2, 9, 31, -10, 38, -34, 17, 10, 39, 26, 6, -27, -8, -14, -30, -20, 25, 21, -35, 32, -29, -11, -5, -19]

Why

`reverseArrayValues` returns `[5, -13, -22, 16, 18, 28, -34, 0, 12, -37, 24, 33, 13, -15, 4, -32, 28, 2, 9, 31, -10, 38, -34, 17, 10, 39, 26, 6, -27, -8, -14, -30, -20, 25, 21, -35, 32, -29, -11, -5, -19]` for this input.

Example 2

reverseArrayValues()
Input
nums = [-12, 17, 13, -25, -5, -39, -14, -19, -15, -27, 21, 5, -8, -12, -23, 27, -14, -11, 13, 27, -1, 27, -12, 28, 20, -20, -22, -30, -20, 22, 25, 37, -29, -7, 17, 32, 38, 20, 19, 9, -2, -26, -10]
Output
[-10, -26, -2, 9, 19, 20, 38, 32, 17, -7, -29, 37, 25, 22, -20, -30, -22, -20, 20, 28, -12, 27, -1, 27, 13, -11, -14, 27, -23, -12, -8, 5, 21, -27, -15, -19, -14, -39, -5, -25, 13, 17, -12]

Why

`reverseArrayValues` returns `[-10, -26, -2, 9, 19, 20, 38, 32, 17, -7, -29, 37, 25, 22, -20, -30, -22, -20, 20, 28, -12, 27, -1, 27, 13, -11, -14, 27, -23, -12, -8, 5, 21, -27, -15, -19, -14, -39, -5, -25, 13, 17, -12]` 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.