#1854
Maximum Population Year
pupil · 360 · lc easy +23 · premium · verified · 63.7% accepted · 1,543 likes · top 66%
Description
You are given logs[i] = [birthi, deathi] representing the birth and death years of the i-th person. A person is considered alive during year x if birthi <= x < deathi.
Return the earliest year with the maximum population count.
Example 1:
Input: logs = [[1993,1999],[2000,2010]]
Output: 1993
Explanation: The maximum population is 1, and 1993 is the earliest year with this population.
Example 2:
Input: logs = [[1950,1961],[1960,1971],[1970,1981]]
Output: 1960
Explanation:
The maximum population is 2, and it had happened in years 1960 and 1970.
The earlier year between them is 1960.
Code
1
2
3