202 - 179 最大数
Last updated
Was this helpful?
Last updated
Was this helpful?
给定一组非负整数,重新排列它们的顺序使之组成一个最大的整数。
示例 1:
输入: [10,2] 输出: 210
示例 2:
输入: [3,30,34,5,9] 输出: 9534330
说明: 输出结果可能非常大,所以你需要返回一个字符串而不是整数。
就。根据第一位排序、再第二位排序,然后输出。
官方看不懂的骚操作😂😂
Runtime: 36 ms, faster than 73.50% of Python3 online submissions for Largest Number.
Memory Usage: 12.7 MB, less than 100.00% of Python3 online submissions for Largest Number.
这个算法思路是,把数字变到小数点后面很多位数
比如12变成0.121212…
,121变成0.121121121...
据此排序,就是结果了,直接拼成字符串即可
Runtime: 36 ms, faster than 73.50% of Python3 online submissions for Largest Number.
Memory Usage: 12.8 MB, less than 100.00% of Python3 online submissions for Largest Number.