Question d’entretien chez Yandex

Solve the least common ancestor problem