GBG Interview Question

one dynamic problem. 2 pointer problems