Domanda di colloquio di Google

solving with two pointer question