DDell Technologies·DSASDE-2Onsite – Coding 1
Lowest Common Ancestor in a BST
Problem
Find the LCA of two nodes in a binary search tree without recursion.
Example
BST; LCA splits where p and q diverge
Constraints
- Nodes exist in the tree
Approach
Walk down: go left/right based on values until the split point. O(h).
added 6 days ago