Pregunta de entrevista de Goldman Sachs

the question was leet code easy