Domanda di colloquio di YANDEX

got task to solve with two pointers