Trains the technique from
LeetCode 799Champagne TowerThis 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.
Glasses are stacked in rows: one on the top row, two on the row below, three on the row below that, and so on. Every glass holds one measure when full.
Each glass rests so that anything overflowing it is shared out evenly between the two glasses directly beneath, one to its left and one to its right. Overflow running off either end of a row spills to the floor and is gone.
poured measures are poured into the top glass. Once everything has settled, return how full the glass sitting at position glass along row row is, counting the top glass as row 0 and counting the glasses along each row from 0.
Example 1
Two measures fill the top glass and leave one over, which shares evenly between the two glasses beneath, so each of them holds half a measure.
Example 2
One measure fills the top glass exactly, with nothing left to overflow, so the row below stays dry.
Example 3
The first thirty-four rows hold five hundred and ninety-five measures between them, and far more than that is poured, so every glass in them is full.
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 champagne_tower(poured: int, row: int, glass: int) -> float:public double champagneTower(int poured, int row, int glass)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.