Description
Given a 2D array logs where logs[i] = [birth_i, death_i], return the earliest year with the maximum population alive.
Examples
Input:
logs = [[1993,1999],[2000,2010]]Output:
1993Explanation:
1993-1998 each have 1 person.
Input:
logs = [[1]]Output:
1Explanation:
With a single log entry, the year with maximum population is determined by that entry alone.
Input:
logs = [[1950,1961],[1955,1965],[1960,1970]]Output:
1960Explanation:
From 1950-1954: 1 person alive. From 1955-1959: 2 people alive. From 1960-1960: 3 people alive (maximum). From 1961-1964: 2 people alive. From 1965-1969: 1 person alive. The earliest year with maximum population (3 people) is 1960.
Constraints
- •
1 ≤ logs.length ≤ 100