Problem 236 · Medium

Lowest Common Ancestor of a Binary Tree

Post-order DFS: the first node where both targets are found in separate subtrees is the LCA.

Open the interactive visualisation