Skip to main content
Admissions guidance, study banks, and career tools โ€” get started on Shalyam

Lowest Common Ancestor of a BST

Given a BST (level-order form) and two node values p and q present in the tree, print the value of their lowest common ancestor.

Constraints

2 <= number of nodes <= 10^5 All values are unique

Discussion

No discussions yet.

Rewards ยท v2.1

Join Shalyam Newsletter

Get exclusive insights with every issue: education, research and innovation news.

One email a week. Unsubscribe any time.