Problem
Given a list of non negative integers, arrange them such that they form the largest number.
Example 1:
1 |
|
Example 2:
1 |
|
Note: The result may be very large, so you need to return a string instead of an integer.
Explanation
-
If we find out the most significatn digit by using
c = n / Math.pow(10, log10(n))
, then it’s complicated. -
We can convert each integer number to string, then make a comparator to compare two string’s concatnation and sort them.
-
Special case is if the first string starts with
0
like00
, we can return0
as the result.
Solution
1 |
|