179
Given a list of non negative integers, arrange them such that they form the largest number.
Example 1:
1 | Input: [10,2] |
1 | Input: [3,30,34,5,9] |
Note: The result may be very large, so you need to return a string instead of an integer.
思路
关键点就在于,如何对比两个数的大小?(理解为两个数谁应该放在前面),解法是按照顺序拼接两个字母串进行比较,如果a +b串 大于 b+a串,那么a比较大(即题意中理解的a应该放在前面),反之b比较大
1 | class Solution: |