GBG interview question

one dynamic problem. 2 pointer problems