Hackerrank Solution For Day 7: Arrays

Problem:- Write a Hackerrank Solution For Day 7: Arrays or Hacker Rank Solution Program In C++ For " Day 7: Arrays " or Hackerrank 30 days of code Java Solution: Day 7: Arrays solution or Hackerrank solution for 30 Days of Code Challenges.

Logic:- This is a very simple problem, here we need to only reverse the array and print the element of the array. As we know that array index starts with zero to n-1. here we just reverse the array by first print the array last index than second last index like n, n-1, n-2,..................... up to (greater or equal) 0 (Zero),

Example:- suppose array with 5 elements is 10, 20, 30, 40, 50 and index of the array is 0, 1, 2, 3, 4 so first print index 4 and element 50 then index 3 and element 40 and so on up to index 0 and element 10. Check the below picture its shows how exactly array is printing the element in reverse order.

Hacker rank Solution For Day 7: Arrays

All solution provided here are in C++ (CPP) if you want these solutions in C, and Java comments below or sends a mail with your query like " day n solution in C / C++ / Java. If you want to 30 days solution (All previous solution from day 0 ) from Day 0 please check the below link. You can also find more program in below of this post. Check the below solution with the full explanation (explanation in simple language).

Copy the colored code and paste it into hacker rank editor. If you have any query feel free to share with me, and if you like my work please share, comments and subscribe this will help you update all about new post this Article.

Submit Your Solution Here:- Click Here


#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <unordered_map>

using namespace std;

int main()

 int n;
 cin >> n;

 vector<int> arr(n);

 for(int arr_i = 0;arr_i < n;arr_i++)
       cin >> arr[arr_i];

for(int arr_i = n-1;arr_i >= 0;arr_i--)
       cout << arr[arr_i]<<" ";
    return 0;


Hackerrank Solution For Day 7: Arrays output

You May Also Like:-

5. Hackerrank Solution For Day 12: Inheritance
Previous Post
Next Post

post written by:

Hi, I’m Ghanendra Yadav, SEO Expert, Professional Blogger, Programmer, and UI Developer. Get a Solution of More Than 500+ Programming Problems, and Practice All Programs in C, C++, and Java Languages. Get a Competitive Website Solution also Ie. Hackerrank Solutions and Geeksforgeeks Solutions. If You Are Interested to Learn a C Programming Language and You Don't Have Experience in Any Programming, You Should Start with a C Programming Language, Read: List of Format Specifiers in C.
Follow Me