Skip to content

Practice Maximum Population Year

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#1854
LeetCode Problem

Maximum Population Year

Problem Statement

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.

Source: Maximum Population Year on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
logs = [[1993,1999],[2000,2010]]
Output
1993

# Example 2

Input
logs = [[1950,1961],[1960,1971],[1970,1981]]
Output
1960

Constraints

1 <= logs.length <= 100
1950 <= birthi < deathi <= 2050

Related LeetCode Problems

Practice more problems similar to Maximum Population Year.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.