Skip to content

Find the lowest common ancestor of two nodes in a binary tree.

Whether you can reason recursively about a tree without drawing the whole thing, and whether you notice what the tree guarantees.

CodingStandard

Who reports being asked this

LinkedIn · Meta · Microsoft

Attested by 2 independent sources, including 2 first-hand reports, most recently around 2026-08.

What a strong answer does

The first clarification I would ask is whether this is a binary search tree or just an arbitrary binary tree. If it is a BST, the ordering property makes the problem much simpler: starting at the root, if both target values are smaller than the current node, go left; if both are larger, go right; otherwise the current node is where the paths split, so it is the lowest common ancestor. It is worth saying this out loud because jumping directly to the general-tree recursion can look like missing an important guarantee.

All interview questions