Pergunta de entrevista da empresa Yandex

Solve the least common ancestor problem