Dsa
Binary Search Tree
Hard
Find Lowest Common Ancestor in BST
Given a binary search tree and two values, find the lowest common ancestor (LCA) of the two nodes. The binary search tree is created from a list of integers, and the two values are provided separately. The output should be the value of the LCA node.
Example Input:
5 2 8 1 3 7 9
2
8
Example Output:
5
Key concepts
binary_search_treelowest_common_ancestortree_traversal
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now