Medium · Hash Maps

Find Year With Most Population

Given a non-empty list of people as [birth, death] year pairs, where each person counts as alive in every year from birth through death inclusive, return the earliest year in which the largest number of people were alive.

Examples

Example 1

[[1993,1999],[2000,2010]]

Output: year 1993

Example 2

[[1950,1961],[1960,1971],[1960,1971]]

Output: year 1960

Rebuild it in the studio

Core interview problems are free with a full runner and lessons; Pro opens the complete library.

More Hash Maps problems