Search
⌘K

Leetcode 235. Lowest Common Ancestor of a Binary Search Tree

Given a BST and two nodes p and q, find their lowest common ancestor — the deepest node that is an ancestor of both. Leverage BST ordering to traverse from the root until you reach the first node where p and q fall on different sides (or equal the node), which is the LCA.

Asked at:

LinkedIn

LinkedIn


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Early January, 2026

LinkedIn

LinkedIn

Mid-level

what happen if one of the element not in the tree?

Mid December, 2025

LinkedIn

LinkedIn

Junior

Late November, 2025

LinkedIn

LinkedIn

Senior

Comments

Your account is free and you can post anonymously if you choose.