Pregunta de entrevista de Amazon

Nothing too difficult although one should be strong with using data structures.