Amazon Sample Questions Flashcards
1
Q
Most People Alive
Given a list of people with their birth and end years (all between 1900
and 2000
), find the year with the most number of people alive.
A
Create 2 tables, birthdates and deathdates.
Accumulate birth dates and death dates in those tables.
Browse those tables to accumulate the number of alive people at the time.
Grand total complexity is O(n)