Question d’entretien chez YANDEX

got task to solve with two pointers