Lowest Common Ancestor of a Binary Search Tree
Given the root of a binary search tree (BST) and the values of two distinct nodes p and q in the tree, return the value of their lowest common ancestor (LCA).
The LCA is the deepest node that...
Example
Unlock to view complete problem details
and practice with sample input/output
Was this article helpful?
View Test Cases & Run Code requires membership
Standard Input
Execution Result:
