class Solution:
def minNumber(self, nums: List[int]) -> str:
length = len(nums)
nums = [str(val) for val in nums ]
for i in range(length-1):
for j in range(i+1,length):
if not self.a_smaller_than_b(nums[i],nums[j]):
nums[i],nums[j] = nums[j],nums[i]
res = ''
for each in nums:
res += each
return res
def a_smaller_than_b(self,a,b):
return True if int(a+b) <= int(b+a) else False
Leetcode刷题记录——剑指 Offer 45. 把数组排成最小的数
最新推荐文章于 2022-07-16 22:39:14 发布