from functools import cmp_to_key
def compare(first_num_str, second_num_str):
first_sum = int(first_num_str + second_num_str)
second_sum = int(second_num_str + first_num_str)
return second_sum - first_sum
def solution(numbers):
number_str_list = list(map(str, numbers))
sorted_number_str_list = sorted(number_str_list, key=cmp_to_key(compare))
return str(int(''.join(sorted_number_str_list)))
'Problem-solving > 프로그래머스' 카테고리의 다른 글
프로그래머스 - 전화번호 목록 (Python) (0) | 2020.05.08 |
---|---|
프로그래머스 - 더 맵게 (Python) (0) | 2020.05.07 |
프로그래머스 - 소수 찾기 (Python) (0) | 2020.05.06 |
프로그래머스 - 괄호 변환 (C++) (0) | 2020.04.27 |
프로그래머스 - 큰 수 만들기 (C++) (0) | 2020.04.16 |
댓글