lifespans is a pair [birth, death]: the year a person was born and the year they died.
A person counts as alive in year x when birth ≤ x < death. They are no longer counted in the year of their death.
Find the year in which the most people were alive at the same time. If several years tie, return the earliest one.lifespans=[[1960, 1975], [1970, 1990], [1985, 2000]] → 1970
From 1970 through 1974 two people are alive at once, the first and the second. Two are also alive in 1985–1989, but 1970 is the earliest year with that count.
lifespans=[[2001, 2010], [2010, 2020]] → 2001
The first person no longer counts in 2010, so no more than one person is ever alive at a time and the answer is the earliest year, 2001.
lifespans=[[1990, 2000], [1995, 2005], [1998, 2003], [1950, 2050]] → 1998
lifespans=[[1960, 1975], [1970, 1990], [1985, 2000]]
1970
Run checks the first 3 tests in your browser. Submit checks all 93 tests on the server, hidden ones included.