leetcode 上的一道题:Largest Number

2015-09-15 0 691
leetcode 上的一道题:Largest Number
class Solution:
    # @param num, a list of integers
    # @return a string
    def largestNumber(self, num):
        num = [str(x) for x in num]
        print num
        num.sort(cmp=lambda x, y: cmp(y+x, x+y))
        return ''.join(num).lstrip('0') or '0'

遇见资源网 python leetcode 上的一道题:Largest Number http://www.ox520.com/15787.html

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务