Goldman Sachs interview question

Questions based on stack and 2 pointer