30. Largest Number

Arrange the non-negative integers in nums so that, written one after another, they form the largest possible number. Return it as a string.

Example 1

Input: nums = [10,2]
Output: "210"

Example 2

Input: nums = [3,30,34,5,9]
Output: "9534330"
Hint 1

Normal numeric sorting fails: 9 must come before 34.

Hint 2

Compare two strings a and b by which concatenation, a+b or b+a, is larger.

SortingGreedyString