**Problem:-**Vector-Sort Hacker Rank Solution or Vector-Sort hacker rank solution c++ orMulti Level Inheritance in java or Vector-Sort solution or Vector-Sort solution in C++ or Vector-Sort hacker rank solution in Java or Vector-Sort hacker rank solution c++ or Vector-Sort hacker rank solution c++ or Vector-Sort program in c or Vector-Sort solution in C or Hacker Rank Solution For Vector-Sort in C++ or Vector-Sort in C++ or Hacker Rank solution for Vector-Sort in C++.

**Explanation:-**Check this some vector functions.

**Declaration:**

vector<int>v; (creates an empty vector of integers)

**Size:**

int size=v.size();

**Pushing an integer into a vector:**

v.push_back(x);(where x is an integer.The size increases by 1 after this.)

**Popping the last element from the vector:**

v.pop_back(); (After this the size decreases by 1)

**Sorting a vector:**

sort(v.begin(),v.end()); (Will sort all the elements in the vector)

**Check-**Geeksforgeeks solution for School, Basic, Easy, Medium, Hard Domain.

**Submit your solution here:-**Click here

**Solution:-**

#include <cmath>

#include <cstdio>

#include <vector>

#include <iostream>

#include <algorithm>

using namespace std;

int main()

{

int n,i;

cin>>n;

vector<int> arr(n);

for(i=0;i<n;i++)

cin>>arr[i];

{

sort(arr.begin(),arr.end());

}

for(i=0;i<n;i++)

{

cout<<arr[i]<<" ";

}

return 0;

}

1. Hacker Rank Solution Program In C++ For " Vector-Erase "

2. Hacker Rank Solution Program In C++ For " Lower Bound-STL"

3. Hacker Rank Solution Program In C++ For " Sets-STL "

4. Hacker Rank Solution Program In C++ For " Maps-STL"

5. Hacker Rank Solution Program In C++ For " Print Pretty"

6. Hacker Rank Solution For Birthday Cake Candles

7. C++ Program For Store Employee Information And Display Using Structure

8. C Program For Find A Grade Of Given Marks Using Switch Case

9. C Program For HEAP Sort In Ascending Order Also Show Complexity

10. C++ Program For Selection Sort Using Function

sort(arr.begin(),arr.end());

}

for(i=0;i<n;i++)

{

cout<<arr[i]<<" ";

}

return 0;

}

**Output:-**

**You May Like This**

1. Hacker Rank Solution Program In C++ For " Vector-Erase "

2. Hacker Rank Solution Program In C++ For " Lower Bound-STL"

3. Hacker Rank Solution Program In C++ For " Sets-STL "

4. Hacker Rank Solution Program In C++ For " Maps-STL"

5. Hacker Rank Solution Program In C++ For " Print Pretty"

6. Hacker Rank Solution For Birthday Cake Candles

7. C++ Program For Store Employee Information And Display Using Structure

8. C Program For Find A Grade Of Given Marks Using Switch Case

9. C Program For HEAP Sort In Ascending Order Also Show Complexity

10. C++ Program For Selection Sort Using Function

## 0 Comments: