DevJourney · code I wrote while learning

Reverse Elements of an Array

2 items

README.md

Reverse Elements of an Array

Single File Programming Question

Problem Statement

Sarah is tasked with creating a program that reverses the elements of an array using generics in Java.

Can you help her with this?

Input:

format :

The first line of input consists of an integer n, representing the size of the array.

The second line consists of n integers, representing the elements of the array.

Output:

format :

The first line of the output displays the original array in the square bracket where elements are separate by a comma and a space.

The second line displays the reversed integer array in the square bracket where elements are separate by a comma and a space.

Refer to the sample output for the formatting specifications.

Code constraints : 1 ≤ n ≤ 100

1 ≤ array elements ≤ 1000

Sample test cases :

Input 1:

5
1 2 3 4 5
Output 1 :
[1, 2, 3, 4, 5]
[5, 4, 3, 2, 1]
Input 2 :
3
9 8 7
Output 2 :
[9, 8, 7]
[7, 8, 9]