Easy · Arrays

Reverse array

Given an integer array nums, reverse the order of its elements in place using O(1) extra space. Nothing is returned: nums itself is the result.

Examples

Example 1

[1,2,3,4,5]

Output: [5,4,3,2,1]

Example 2

[7,3,9,2]

Output: [2,9,3,7]

Rebuild it in the studio

Open every published interview problem, solution, scene, and memory room free, with no account.

More Arrays problems