dsa · easy
Reverse Array
GreyOrangeArrayTwo PointersFoundation
Reverse nums in place and return it.
Arguments
nums— the input array of integers
**Example:** [1,2,3,4] → [4,3,2,1].
Constraints
0 <= nums.length <= 10^5 Hidden tests include near-max size for this bound; a slower-than-intended solution TLEs.
Examples
Example 1
Input: [1,2,3,4] Expected: [4,3,2,1]
Example 2
Input: [1] Expected: [1]