Question d’entretien chez Yandex

-How would you solve this problem?