from itertools import permutations
def solution(numbers):
numbers = list(map(str, numbers))
numbers.sort(key = lambda x : x*3, reverse=True)
answer = str(int(''.join(numbers)))
return answer
๋ค๋ฅธํ์ด
import functools
def comparator(a,b):
t1 = a+b
t2 = b+a
return (int(t1) > int(t2)) - (int(t1) < int(t2)) # t1์ด ํฌ๋ค๋ฉด 1 // t2๊ฐ ํฌ๋ค๋ฉด -1 // ๊ฐ์ผ๋ฉด 0
def solution(numbers):
n = [str(x) for x in numbers]
n = sorted(n, key=functools.cmp_to_key(comparator),reverse=True)
answer = str(int(''.join(n)))
return answer
'๐ Python > ํ๋ก๊ทธ๋๋จธ์ค' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[์์ ํ์] ๋ชจ์๊ณ ์ฌ (0) | 2022.04.13 |
---|---|
[์ ๋ ฌ]H-index (0) | 2022.04.01 |
[์ ๋ ฌ]k๋ฒ์งธ ์ (0) | 2022.03.28 |