SDE Path

Reverse an Array Using Recursion

Easy

Reverse an Array Using Recursion

Reverse an array in-place using a recursive two-pointer approach.

Input format

The first line contains N (N ≤ 500). The second line contains N integers.

Output format

Print the array reversed, space-separated.

Constraints

  • Values fit in a 64-bit signed integer
  • Trailing whitespace and a trailing newline are ignored by the judge

Read from stdin, write to stdout. Sample cases below show the exact format.

Sample cases

Example 1
Input
5
1 2 3 4 5
Expected output
5 4 3 2 1
Example 2
Input
1
7
Expected output
7