Skip to content

Latest commit

 

History

History
34 lines (22 loc) · 875 Bytes

0179-largest-number.adoc

File metadata and controls

34 lines (22 loc) · 875 Bytes

179. Largest Number

这道题很容易想到需要根据数字的字符串大小进行倒序排列(目的是将首个数字比较大的数字排在前面)。很容想到需要自定义 Comparator。最简单省事的方式就是直接将排序的两个字符串相加(左右,右左)进行比较就可以了。

Given a list of non negative integers, arrange them such that they form the largest number.

Example 1:

Input: [10,2]
Output: "`210"`

Example 2:

Input: [3,30,34,5,9]
Output: "`9534330"`

Note: The result may be very large, so you need to return a string instead of an integer.

link:{sourcedir}/_0179_LargestNumber.java[role=include]