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

Core interview problems are free with a full runner and lessons; Pro opens the complete library.

More Arrays problems