You are given a list of integers nums. Rearrange the numbers into some order and write them one after another, in decimal, to get the largest possible number. Return that number as a string.
If every number in nums is 0, return "0" instead of a string of zeros.
Examples
Example 1
Input: nums = [10,2]
Output: "210"
Explanation: Writing 2 before 10 gives "210", which is larger than writing 10 before 2, "102".
Example 2
Input: nums = [3,30,34,5,9]
Output: "9534330"
Example 3
Input: nums = [0,0]
Output: "0"
Explanation: Every number is 0, so the answer is "0" rather than "00".
Constraints
1≤n≤1000 where n=nums.length
0≤nums[i]≤1000
Loading editor...
Run checks the sample cases; Submit runs every case.
Samples 3
Custom 0
passedwrong answertime limiterrorran, no expected valuenot run