Goldman Sachs interview question

given some codes to debug