Pregunta de entrevista de Amazon

How do you solve the difficulty