Description
Given a list of non-negative integers nums, arrange them such that they form the largest number and return it as a string.
Examples
Input:
nums = [10,2]Output:
"210"Explanation:
210 > 102.
Input:
nums = [0,0,0]Output:
0Explanation:
When all numbers are zeros, the result should be a single "0" rather than "000". This handles the edge case where multiple zeros should be collapsed to avoid leading zeros in the final result.
Input:
nums = [432,43]Output:
43432Explanation:
To determine the order, comparing concatenations: "43243" vs "43432". Since 43432 > 43243, placing 43 before 432. This shows how to handle cases where one number is a prefix of another.
Constraints
- •
1 ≤ nums.length ≤ 100 - •
0 ≤ nums[i] ≤ 10⁹