115 - Climbing Trees

Given pairs of nodes in a forest, you are asked to find their common ancestors.

Here is a reference solution of the problem.

Creative Commons License
This blog by Che-Liang Chiou is licensed under a Creative Commons Attribution 4.0 International License.