We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • HackerRank Home
  • |
  • Prepare
  • Certify
  • Compete
  • Apply
  • Hiring developers?
  1. Prepare
  2. Data Structures
  3. Arrays
  4. Arrays - DS

Arrays - DS

Problem
Submissions
Leaderboard
Discussions
Editorial
HackerRank Logo
|
  1. Prepare
  2. Data Structures
  3. Arrays
  4. Arrays - DS
Exit Full Screen View
  • Problem
  • Submissions
  • Leaderboard
  • Discussions
  • Editorial

An array is a type of data structure that stores elements of the same type in a contiguous block of memory. In an array, , of size , each memory location has some unique index, (where ), that can be referenced as or .

Reverse an array of integers.

Note: If you've already solved our C++ domain's Arrays Introduction challenge, you may want to skip this.

Example

Return .

Function Description

Complete the function reverseArray in the editor below.

reverseArray has the following parameter(s):

  • int A[n]: the array to reverse

Returns

  • int[n]: the reversed array

Input Format

The first line contains an integer, , the number of integers in .
The second line contains space-separated integers that make up .

Constraints

Sample Input 1

CopyDownload
G Array: arr node1 1 4 3 2
4
1 4 3 2

Sample Output 1

2 3 4 1

  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy

Cookie support is required to access HackerRank

Seems like cookies are disabled on this browser, please enable them to open this website