Domanda di colloquio di Yandex

-How would you solve this problem?