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

Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.

More Arrays problems