Ticker

6/recent/ticker-posts

HackerRank Program Solution for Arrays-DS



In this program, we have to complete the function reverse array in the editor. And the reverseArray has the following parameter(s): like int A[n]: the array to reverse.


Input Format - 

In the first line, it contains the integer n. The number of elements in Array.

In the second line, it contains n separated integers that makeup Array A.


In this program, we used a reverse () function from STL.

Syntax - reverse(a.begin(), a.end())

Then run a loop from i = 0 to i <n and print the elements.

Here is the link for the statement.(click here)

Input and Output format

Input:

4

1 4 3 2

Output:

2 3 4 1

Here is the implementation below. :



Post a Comment

0 Comments