Trains the technique from
LeetCode 441Arranging CoinsThis 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 shop builds a stepped display of tins. Tier 1 across the top holds one tin, tier 2 below it holds two tins, and in general tier i holds i tins.
With n tins in stock, the staff work downwards and fill each tier completely before starting the next one, stopping when the stock runs short of what the next tier needs. Return how many tiers end up complete.
Example 1
Tier 1 takes 1 tin, tier 2 takes 2 and tier 3 takes 3, which uses 6 of the 7 tins. Tier 4 needs 4 tins and only 1 is left, so 3 tiers are complete.
Example 2
The first 44720 tiers take 999961560 tins altogether, leaving 38439 tins. Tier 44721 needs 44721 tins, which is more than what is left, so 44720 tiers are complete.
Example 3
Tiers 1, 2 and 3 take 1, 2 and 3 tins, using the stock exactly, so all 3 tiers are complete and nothing is left over.
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 arrange_coins(n: int) -> int:public int arrangeCoins(int n)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.