Goldman Sachs interview question

LC easy and debugging (fix some logical errors in the question)