Given a list of non-negative integers nums , arrange them such that they form the largest number and return it. Since the result may be very large, so you need to return a string instead of an integer.
Example 1:
Input: nums = [10,2]
Output: "210"
Example 2:
Input: nums = [3,30,34,5,9]
Output: "9534330"
1 of 4
What is the optimal approach for this problem?
A. Sort by string length first, then by value, which doesn't correctly handle all orderings.B. Convert each number to a string, then sort using a custom comparator: for two strings a and b, compare a+b vs b+a to decide ordering. For example, '9' vs '34': '934' > '349', so '9' comes first. If the result starts with '0', the entire number is 0.C. Sort numbers in descending order and concatenate—this fails for cases like [3, 30].D. Use DP to find the arrangement with the maximum concatenated value.