Goldman Sachs interview question

Questions based on stack and DP.