- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbiggestNumber.cpp
More file actions
Latest commit
27 lines (19 loc) · 437 Bytes
/
Copy pathbiggestNumber.cpp
File metadata and controls
27 lines (19 loc) · 437 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
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
usingnamespacestd;
boolcmp(string a, string b) {
return a + b > b + a;
}
string solution(vector<int> numbers) {
string answer = "";
vector<string> temp;
for (auto num : numbers)
temp.push_back(to_string(num));
sort(temp.begin(), temp.end(), cmp);
if (temp.front() == "0") return"0";
for (auto num : temp)
answer += num;
return answer;
}