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

Level up your interview prep. Join Educative to access 80+ hands-on prep courses.