Reverse Array

EasyArrayTwo PointersSorting

Description

Given an array of integers nums, return a new array with the elements in reverse order.

Examples

Input:nums = [1,2,3,4]
Output:[4,3,2,1]
Explanation:

Reading the list from back to front yields [4,3,2,1].

Input:nums = [9]
Output:[9]
Explanation:

Reading the list from back to front yields [9].

Input:nums = [-1,0,1]
Output:[1,0,-1]
Explanation:

Reading the list from back to front yields [1,0,-1].

Constraints

  • 1 ≤ nums.length ≤ 10⁴
  • -10⁹ ≤ nums[i] ≤ 10⁹

Ready to solve this problem?

Practice solo and sharpen your skills for technical interviews.