首先注意事项是字符中。然后就是原理,相邻两个比大小排序,有点类似冒泡排序。 过程例子: alt

#
# 最大数
# @param nums int整型一维数组 
# @return string字符串
#

class Solution:     
    def solve(self , nums ):
        # write code here
        #将整型的数字转化为字符串
        s = nums
        for i in range(len(nums)):
            s[i] = str(s[i])
        for i in range(len(nums)):
            for j in range(len(nums)-i-1):
                a = nums[j]
                b = nums[j+1]
                if int("".join([b, a])) > int("".join([a, b])):
                    s[j], s[j+1] = s[j+1], s[j]
        if s[0]=='0':
            return '0'
        return "".join(s)