Skip to the code
cf.
+25 XP

#220 Biggest Banner Number

medium

A promo banner is built by placing number stickers side by side. nums lists the stickers' values, and every sticker must be used exactly once. The marketing team wants the arrangement that reads as the biggest possible number.

Write biggestBanner(nums) that returns that number as a string (it can be too long for a JavaScript number). If the result would have leading zeros, return just "0".

Example 1

Input: nums = [10,2]
Output: "210"

"2" + "10" is "210", bigger than "102".

Example 2

Input: nums = [4,40,45,7,8]
Output: "8745440"

4 goes before 40 because "440" beats "404".

Constraints

  • 1 <= nums.length <= 1000
  • 0 <= nums[i] <= 10^9
Saved in this browser

Run tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.

Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).