Goldman Sachs interview question

the question was leet code easy