Tap here to switch tabs
Problem
Submissions

Problem: Maximum Population Year

med
30 min
Try to solve the Maximum Population Year problem.

Statement

You are given a two dimensional integer array logs where each logs[i] = [birth_i, death_i] indicates the birth and death years of the iextthi^{ ext{th}} person.

The population of a given year is the total number of people alive during that year. A person is considered alive during every year in the inclusive range from birth_i to death_i −1- 1.

Return the earliest year that achieves the maximum population.

Note: A person is not considered alive in their death year death_i.

Constraints:

  • 1≤1 \leq logs.length ≤100\leq 100

  • 1950≤1950 \leq birth_i << death_i ≤2050\leq 2050

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximum Population Year

med
30 min
Try to solve the Maximum Population Year problem.

Statement

You are given a two dimensional integer array logs where each logs[i] = [birth_i, death_i] indicates the birth and death years of the iextthi^{ ext{th}} person.

The population of a given year is the total number of people alive during that year. A person is considered alive during every year in the inclusive range from birth_i to death_i −1- 1.

Return the earliest year that achieves the maximum population.

Note: A person is not considered alive in their death year death_i.

Constraints:

  • 1≤1 \leq logs.length ≤100\leq 100

  • 1950≤1950 \leq birth_i << death_i ≤2050\leq 2050