Solution Review: Least Common Ancestor
Let’s take a detailed look at the previous challenge’s solution.
We'll cover the following
Solution
For a given tree T
, the LCA between two nodes n1
and n2
is the lowest node in T
that has both n1
and n2
as its descendants.
Solution code
Get hands-on with 1400+ tech skills courses.