5. Maximum Population Year
You are given a 2D integer array logs
where each logs[i] = [birthi, deathi]
indicates the birth and death years of the ith
person.
The population of some year x
is the number of people alive during that year. The ith
person is counted in year x
's population if x
is in the inclusive range [birthi, deathi - 1]
. Note that the person is not counted in the year that they die.
Return the earliest year with the maximum population.
Example 1:
Example 2:
Solution: (Similar to car pooling)
Maintaining the count of population at each time stamp
Last updated