Given a list of non negative integers, arrange them such that they form the largest number.
Example
Given [3, 30, 34, 5, 9],
The largest formed number is 9534330.
Note:
The result may be very large, so you need to return a string instead of an integer.
Solution
- 对于两个备选数字a和b,如果str(a) + str(b) > str(b) + str(a),则a在b之前,否则b在a之前
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
|