Pregunta de entrevista de Apple

Data structures and algorithms coding question