Pregunta de entrevista de Uber

Regular algorithm and data structure question.