Trains the technique from
LeetCode 739Daily TemperaturesThis 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 repertory theatre keeps a run log: occupancy[i] is the percentage of seats sold on the i-th night of the run, in performance order.
The manager wants to know, for every night, how soon the house got fuller than it was that night. Build an array waits of the same length where waits[i] counts the nights between night i and the earliest night after it whose percentage is strictly above occupancy[i]. Nights that tie do not count as fuller. Put 0 in waits[i] when no later night in the run beats night i.
Example 1
Night 1 already beats night 0, so the first entry is 1. Night 2 and night 3 both sold the same 68 percent, so night 2 has to skip past night 3 and wait for the 95 percent night.
Example 2
The run only thins out, so no night is ever followed by a fuller one.
Example 3
Every night sells the same share of the house, and an equal night is not a fuller night.
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 nights_until_fuller(occupancy: list[int]) -> list[int]:public int[] nightsUntilFuller(int[] occupancy)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.