Skip to content

Commit 7b8f28c

Browse files
committed
89차 3번 문제풀이
1 parent a3ec3d5 commit 7b8f28c

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

live8/test89/문제3/백유진.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from functools import cmp_to_key
2+
3+
def max_num(a, b):
4+
if a+b > b+a:
5+
return -1
6+
elif b+a > a+b:
7+
return 1
8+
return 0
9+
10+
def solution(numbers):
11+
sarr = list(map(str, numbers))
12+
13+
# 정렬 기준: 두 수를 이어붙였을 때 큰 순서대로 정렬
14+
sarr.sort(key=cmp_to_key(max_num))
15+
16+
# 만약 가장 큰 숫자가 0이면 전체가 0이므로 '0' 반환
17+
if sarr[0] == "0":
18+
return "0"
19+
20+
return "".join(sarr)

0 commit comments

Comments
 (0)