Trains the technique from
LeetCode 179Largest NumberThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A packing station prints the part number of every item in a shipment on its own slip, then glues the slips into one row that reads as a single numeral: the shipment tag. The station picks the order of the slips, and each slip is used exactly once with its digits kept as printed.
Given the part numbers parts, return the greatest tag the station can glue, as a string. A tag is never printed with a leading zero, so when every part number is 0 the tag reads "0". The answer comes back as a string because a tag can run far past what a machine integer holds.
Example 1
Gluing 7 in front gives 770, while 70 in front gives 707, so 7 leads.
Example 2
The order 25, 251, 2 reads as 252512, which beats every other arrangement, including 251 first at 251252.
Example 3
2 leads, then 10, then 0; putting 0 anywhere earlier only shrinks the tag.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def greatest_tag(parts: list[int]) -> str:public String greatestTag(int[] parts)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.