← Questions

Lowest common ancestor in a BST and in a binary tree

0
MicrosoftCodingLast asked Jun 2026

A coding interview question asked in Microsoft's recruiter screen, last asked Jun 2026. It tests trees and recursion.

Given the root of a tree and two values that occur in it, return the value of their lowest common ancestor: the deepest node that has both in its subtree (a node counts as its own descendant). Solve it first for a binary search tree…

Sign in to unlock this question

The full prompt, the worked answer and your own canvas or code with the AI tutor. New accounts get 5 credits: each one unlocks a question for good.

Where it's asked

What it tests

trees · recursion

Your code and the AI tutor open when you unlock this question.