dsa1 min read
Lowest Common Ancestor of Binary Tree — Post-Order DFS
Find the LCA of two nodes using post-order DFS: return root when found, propagate upward and split at the ancestor.
Read →
webcoderspeed.com
3 articles
Find the LCA of two nodes using post-order DFS: return root when found, propagate upward and split at the ancestor.
Find the LCA in a BST in O(h) by navigating left or right based on whether both nodes are in the same subtree.
Find path directions between two tree nodes by finding LCA then building paths from LCA to each target.