Pregunta de entrevista de Amazon

to answer a programming problem