Question d’entretien chez Yandex

Some leetcode task, which wasn't hard