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

    HackerRank

  • |
  • Prepare
  • Certify
  • Compete
  • Apply
  • Hiring developers?
  1. Prepare
  2. C++
  3. Introduction
  4. Arrays Introduction
  5. Discussions

Arrays Introduction

Problem
Submissions
Leaderboard
Discussions

Sort 1262 Discussions, By:

recency

Please Login in order to post a comment

  • dyum429
    1 week ago+ 0 comments

    My solution:

    include

    include

    include

    include

    include

    include

    using namespace std;

    int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */
    int N; cin >> N ; int arr[N]; int inputs;

    for(int i = 0; i< N; i++){
        cin >> arr[i];
    }
    
    stack <int> s1;
    
    for(int i : arr){
        s1.push(i);
    }
    
    while (!s1.empty()) {
        cout << s1.top() << " ";
        s1.pop();
    }
    
    
    return 0;
    

    }

    0|
    Permalink
  • ivanreeve
    3 weeks ago+ 0 comments

    My solution:

    #include <cmath>
    #include <cstdio>
    #include <vector>
    #include <iostream>
    #include <algorithm>
    using namespace std;
    
    
    int main() {
        /* Enter your code here. Read input from STDIN. Print output to STDOUT */
        int size;
        cin >> size;
        
        int arr[size];
        
        for (int i = 0; i < size; i++){
            cin >> arr[i];
        }
        
        for (int j = size-1; j >= 0; j--){
            cout << arr[j] << " ";
        }
        return 0;
    }
    
    1|
    Permalink
  • prabhaths2001
    4 weeks ago+ 0 comments
    int main() {
        int n;
        scanf("%d", &n);
        int arr[n];
        for (int i=0; i<n; ++i){
            scanf("%d", &arr[i]);
        }
        for (int i=n-1; i>=0; --i){
            printf("%d ", arr[i]);
        }
        return 0;
    }
    
    1|
    Permalink
  • btech2021_shiva1
    1 month ago+ 1 comment

    include

    include

    include

    include

    using namespace std;

    int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */

    int n ;
    cin >> n;
    int *arr = new int[n];
    for(int i = 0 ; i < n ; i++)
    {
        cin >> *(arr+i);  
    }
    for (int i = n-1 ; i >=(n/2)  ; i--){
        int k = n-1-i;
        int temp = *(arr+k);
        *(arr+k) = *(arr+i);
        *(arr+i) = temp;
    
    
    }
    for(int i = 0 ; i < n ; i++)
    {
        cout << *(arr+i) << " ";  
    }   
    

    }

    -1|
    Permalink
  • coolutsav888
    1 month ago+ 0 comments

    include

    include

    include

    include

    include

    using namespace std;

    int main() { vector v; int n; cin>>n; for(int i=0;i>x; v.push_back(x); } for(int i=n-1;i>=0;i--) { cout<

    return 0;
    

    }

    0|
    Permalink
Load more conversations

Need Help?


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