Showing posts with label vector. Show all posts
Showing posts with label vector. Show all posts

Friday, January 1, 2021

Vector-Sort | STL | HackerRank | C++ | Solution | Color The Code



Problem : https://www.hackerrank.com/challenges/vector-sort/problem

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 */ 
    vector<int>  v;
    int n;
    cin>>n;
    int temp;
    for(int i =0;i<n;i++){
        cin>>temp;
        v.push_back(temp);
    }
    
    sort(v.begin(),v.end());
    for(int i=0;i<n;i++){
        cout<<v[i]<<" ";
    }
    return 0;
}