forked from Mohammed-Shoaib/Coding-Problems
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathE0026.cpp
More file actions
34 lines (30 loc) · 622 Bytes
/
Copy pathE0026.cpp
File metadata and controls
34 lines (30 loc) · 622 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/*
Problem Statement: https://www.hackerrank.com/challenges/cut-the-sticks/problem
*/
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
vector<int> cutTheSticks(vector<int> arr) {
vector<int> values;
while(arr.size() != 0){
values.push_back(arr.size());
int min = *min_element(arr.begin(),arr.end());
arr.erase(remove(arr.begin(),arr.end(),min),arr.end());
}
return values;
}
int main()
{
int n,num;
vector<int> a,values;
cin>>n;
for(int i=0 ; i<n ; i++){
cin>>num;
a.push_back(num);
}
values = cutTheSticks(a);
for(int value:values)
cout<<value<<endl;
return 0;
}