Lowest Common Ancestor (LCA)

Post-order DFS: bubble up p/q; first node holding both is LCA. LC 236, 235, 1123, 1676.

Unvisited
Current DFS
Target node (p or q)
Carries result up
LCA found

Controls

Time: O(n) | Post-order DFS

Steps