Pregunta de entrevista de Amazon

Problem faced with past project.