본문 바로가기
카테고리 없음

[Programmers] (정렬) Lv 2. 가장 큰 수

by song.ift 2024. 10. 17.

https://school.programmers.co.kr/learn/courses/30/lessons/42746

 

프로그래머스

코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.

programmers.co.kr

 

#include <string>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

string solution(vector<int> numbers) {
    //24.10.17
    string answer;

    sort(numbers.begin(), numbers.end(), [&](const auto& lhs, const auto& rhs) {
        return to_string(lhs) + to_string(rhs) > to_string(rhs) + to_string(lhs);
    });
    for (const auto& n : numbers) answer += to_string(n);
    
    return answer < "1" ? "0" : answer;
}

GitHub : https://github.com/developeSHG/Algorithm-Baekjoon_Programmers/commit/756343af8c319e640fcea85e4b338d2e48391cc5

 

[level 2] Title: 가장 큰 수, Time: 491.59 ms, Memory: 7.32 MB -BaekjoonHub · developeSHG/Algorithm-Baekjoon_Programmers@756

developeSHG committed Oct 16, 2024

github.com

 

댓글