Skip to content
Decoder

Maximum Population Year

Easy

Problem

logs[i] = [birth, death] gives the birth and death years of person i. A person counts toward the population of every year from birth to death - 1: they are not counted in the year they die. Return the year with the largest population. If several years tie, return the earliest one.

Example 1

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

Example 2

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

Constraints

  • 1 <= logs.length <= 100
  • 1950 <= birth < death <= 2050

Read it once before you touch anything

Want some pressure? Start the timer. In an interview you get about two minutes to understand the problem.

  1. 1Read the goalWhat goes in, what comes out
  2. 2Scan the examplesCheck one by hand
  3. 3Note the constraintsThey set your Big O
Say what it asks in one sentence
Say it out loud first, then compare with ours.