美文网首页
2019-08-19 剑指 把数组排成最小的数

2019-08-19 剑指 把数组排成最小的数

作者: mztkenan | 来源:发表于2019-08-19 22:21 被阅读0次

    30min。python的魔法方法map函数,lambda方法,sort方法,还有排序的的思路

    
    class Solution:
        def PrintMinNumber(self, numbers):
            l=map(lambda x:str(x),numbers)
            l.sort(cmp=lambda x,y:cmp(x+y,y+x))  #为什么x+y<y+x不行啊
            return "".join(l)
    

    相关文章

      网友评论

          本文标题:2019-08-19 剑指 把数组排成最小的数

          本文链接:https://www.haomeiwen.com/subject/axlysctx.html