Trains the technique from
LeetCode 1854Maximum Population YearThis 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 market hall keeps one record per shop lease. Entry logs[i] = [start_i, end_i] means that lease occupied a unit from the start of year start_i and was handed back at the start of year end_i, so it counts as active in every year from start_i up to and including end_i - 1, and not in end_i itself.
A year's occupancy is the number of leases active in that year. Return the earliest year whose occupancy is as large as any year's occupancy. If several years share the largest occupancy, return the smallest of them.
Example 1
In 1972 the first lease has just begun and the second is still running, so the occupancy is 2. No year here reaches 3, and 1972 is the first year that reaches 2.
Example 2
The two leases never overlap, so no year has occupancy above 1. Both 1970 and 1990 have occupancy 1, and the smaller of the tied years is returned.
Example 3
The single lease is active in 2049 only, because a lease does not count in its end year.
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 maximum_population(logs: list[list[int]]) -> int:public int maximumPopulation(int[][] logs)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.