Largest Number
Medium Greedy AI round
nums is a list of whole numbers, none of them negative.
Put all of the numbers in a row, in any order you choose, and read their digits one after another as one number. For example, 7 and 45 make 745 or 457.
Return the largest number you can make this way, as a string, since it can be far too long for a number type. It starts with a 0 only when it is 0.
Example 1
Input: nums = [8,81,7]
Output: "8817"
8 goes before 81, since 881 is larger than 818, and 7 goes last: 8817.
Example 2
Input: nums = [0,0,0]
Output: "0"
Example 3
Input: nums = [40,4,404,3]
Output: "4404403"
Constraints
1 ≤ nums.length ≤ 2 × 10⁴0 ≤ nums[i] ≤ 10⁹
Practice this in an AI round
30 minutes on this problem with an AI agent beside your code, then a report on your solution and how you used the agent.
Your first AI round is free.
More Greedy
- Gas StationAI round · Medium
- CandyAI round · Hard
- Increasing Triplet SubsequenceMedium
- Minimum Number of Arrows to Burst BalloonsMedium
- Can Place FlowersEasy