Skip to content

Commit c4f1c91

Browse files
committed
将数组重新排序以构造最小值
1 parent 4ba9481 commit c4f1c91

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
class Solution:
2+
# @param {int[]} nums n non-negative integer array
3+
# @return {str} a string
4+
def minNumber(self, nums):
5+
# Write your code here
6+
# 修改一下排序规则就可以了
7+
nums.sort(lambda x, y: cmp(str(x) + str(y), str(y) + str(x)))
8+
return str(int(''.join(str(i) for i in nums))) # 把前面的0都去掉

0 commit comments

Comments
 (0)