Pregunta de entrevista de Amazon Web Services

Just Explain the approach and write the code.