Skip to content

가장 큰 수 #412

@fkdl0048

Description

@fkdl0048
#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;
}

Metadata

Metadata

Assignees

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions