Pregunta de entrevista de Yandex

Solve the least common ancestor problem