...
/DIY: Lowest Common Ancestor of a Binary Tree III
DIY: Lowest Common Ancestor of a Binary Tree III
Solve the interview question "Lowest Common Ancestor of a Binary Tree III" in this lesson.
We'll cover the following...
Problem statement
Suppose you are given two nodes of a binary tree node1
and node2
. Your task is to find the lowest common ancestor (LCA) of these two nodes in the tree.
Note: The lowest node that has both
node1
andnode2
as its descendants (where we allow a node to be a descendant of itself), is called the lowest ...