Skip to content

Commit

Permalink
이슈 #412에서 솔루션 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Dec 2, 2024
1 parent 1c23b52 commit 23cbc76
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions Programmers/가장_큰_수.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

string solution(vector<int> numbers) {
vector<string> strNumbers;

for (int num : numbers) {
strNumbers.push_back(to_string(num));
}

sort(strNumbers.begin(), strNumbers.end(), [](const string& a, const string& b) {
return a + b > b + a;
});

if (strNumbers[0] == "0") {
return "0";
}

string result = "";
for (const string& num : strNumbers) {
result += num;
}

return result;
}

0 comments on commit 23cbc76

Please sign in to comment.