Reverse Array ElementsEasy

Reverse Array Elements

EasyPractice library · +10 XPtwo pointersarray manipulationbeginner

Given an array of N integers, print the elements of the array in reverse order. The first element of the input array should be the last element of the output, and the last element of the input should be the first element of the output. All other elements should also be in their reversed positions.

Input

The first line contains an integer N, the number of elements in the array. The second line contains N space-separated integers, representing the elements of the array.

Output

Print the N integers of the array in reverse order, separated by spaces.

Constraints

1 <= N <= 1000. Each array element will be an integer between -1000 and 1000.

Time limit 1 s (native code; slower languages get more)Memory 256 MB13 hidden tests

Example 1

Input
5
1 2 3 4 5
Output
5 4 3 2 1

Reverses the array [1, 2, 3, 4, 5] to [5, 4, 3, 2, 1].

Example 2

Input
3
10 20 30
Output
30 20 10

Reverses the array [10, 20, 30] to [30, 20, 10].

Hints