AlgoMaster Logo

Lowest Common Ancestor of a Binary Tree

tree=[3, 5, 1, 6, 2, 0, 8, null, null, 7, 4],p=5,q=1
0 / 10
351620874pqp5q1lca?lowest node with both p and q in its subtree
algomaster.io
Step:Start: find the lowest node that has both p and q in its subtree