Goldman Sachs Interview Question

Questions based on stack and 2 pointer