...

/

Solution: Largest Number

Solution: Largest Number

Let's solve the Largest Number problem using the Greedy Techniques pattern.

We'll cover the following...

Statement

Given a list of non-negative integers, nums, rearrange them so that they form the largest possible number. As the result may be very large, return it as a string.

Constraints:

  • 1≤1 \leq nums.length ≤100\leq 100

  • 0≤0 \leq nums[i] ≤103\leq 10^3

Solution

At first glance, one might think sorting the numbers from largest to smallest would work, but that fails in cases like [3,30][3, 30]. Putting 3030 before ...