Saturday, 1 April 2017

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.


Hacker Rank Solution For Day 7: Arrays

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).

2. Hackerrank Solution For Day 3: Intro to Conditional Statements 

3. Hackerrank Solution For Day 4: Class vs. Instance

5. Hacker Rank Solution For Day 5: Loops

6. Hackerrank Solution For Day 6: Let's Review


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

Solution:-

#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;
}

Output:-

Hackerrank Solution For Day 7: Arrays


You May Also Like:-





5. Hackerrank Solution For Day 12: Inheritance

6. Hackerrank Solution For Day 13: Abstract Classes

7. Hackerrank Solution For Day 14: Scope

8. Hackerrank Solution For Day 15: Linked List

9. Hackerrank Solution For Day 16: Exceptions - String to Integer

10. Hackerrank Solution For Day 17: More Exceptions

Extreme Recommended:- Like our Facebook Page or Join our Facebook Group and Google plus Community for up-to-date. If you have any Query or Question you can ask in the group, I will Try To Solve your Query and try to answers of your Questions withing 24 Hours, You can also Email me or comment below Please suggest to your Friends to join and like our page and don't forget to Subscribe. Enter your Email and click to subscribe.

Ghanendra Yadav

Ghanendra Yadav

Hello, I Am Ghanendra Yadav Owner of This Blog, I am professional Blogger and Programmer. I Love Programming, Logo Making, And Banner Designing. My Highest Qualification is MCA From NIT Warangal. You Can Find Me On Social Media Through Below Link And If You Have Any Query Related To Programming And Other Subject Comment Below or You Can Mail Me I Will Try To Answer Within 24 Hours Email:- yghanendra@student.nitw.ac.in

Find me on Social Media

Facebook | Twitter | Google+ | RSS Feed

No comments:

Post a Comment