1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | from functools import cmp_to_key def solution(numbers): strNums = map(str, numbers) strNums = sorted(strNums, key=cmp_to_key(compare)) return ''.join(strNums) if strNums[0] != '0' else '0' def compare(strNum1, strNum2): num1 = strNum1 + strNum2 num2 = strNum2 + strNum1 if num1 < num2: return 1 elif num2 < num1: return -1 else: return 0 # 프로그래머스 - 가장 큰 수 # https://school.programmers.co.kr/learn/courses/30/lessons/42746 | cs |
'Data Engineering > Python' 카테고리의 다른 글
| [코테] 프로그래머스 - 합승 택시 요금 Python 코드 (0) | 2025.10.16 |
|---|---|
| [코테] 프로그래머스 - 베스트앨범 Python 코드 (0) | 2025.10.15 |
| [코테] 프로그래머스 - 삼각 달팽이 Python 코드 (0) | 2025.10.15 |
| [코테] 프로그래머스 - 시소 짝꿍 Python 코드 (0) | 2025.10.15 |
| [코테] 프로그래머스 - 더 맵게 Python 코드 (0) | 2025.09.18 |