首页
IT
登录
6mi
u
盘
搜
搜 索
IT
leetcode那些让人长见识的代码
leetcode那些让人长见识的代码
xiaoxiao
2021-03-25
173
179. Largest Number
@xcv58 :
def
largestNumber
(self, num)
:
num = [str(x)
for
x
in
num] num.sort(cmp=
lambda
x, y: cmp(y+x, x+y))
return
''
.join(num).lstrip(
'0'
)
or
'0'
@ahmed7:
def
largestNumber
(self, num)
:
comp=
lambda
a,b:
1
if
a+b>b+a
else
-1
if
a+b<b+a
else
0
num=map(str,num) num.sort(cmp=comp,reverse=
True
)
return
str(int(
""
.join(num)))
转载请注明原文地址: https://ju.6miu.com/read-7314.html
技术
最新回复
(
0
)