Problem 4000 · Medium

Largest Integer With Given Digit Sum

Fill the digits from the left with the largest digit that still fits the remaining sum; the result is the largest number of at most n digits with that digit sum.

Open the interactive visualisation