Reverse an Array
easyarraytwo-pointers
Given an integer array nums, reverse the array in-place.
This is a great problem to visualize pointer movement and array mutation.
Example 1
Input: nums = [1, 2, 3, 4, 5]
Output: [5, 4, 3, 2, 1]
Explanation: The array is reversed using two pointers.
Constraints
- •
1 <= nums.length <= 100 - •
-1000 <= nums[i] <= 1000