179. Largest Number
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.
@tog-top100

Algorithm

For two numbers a and b, if you convert them to strings, if ab> ba, then a will be ranked first,

For example, 9 and 34, since 934>349, 9 is in front,

For example, 30 and 3, because 303<330, 3 is in front of 30.

After sorting the original array according to this rule, converting each number into a string and then concatenating it is the final result.