9 binary search tree interview questions, asked at Amazon, Google, Meta and 2 more companies. Last asked Sep 2026.
Binary search tree keys within a rangeCodingGiven a binary search tree (as a level-order list with nulls for missing children) and an inclusive range low, high, return every key in the range in ascending order. Skip the…
Last asked Sep 2026
Lowest common ancestor in a binary search treeCodingGiven a binary search tree and two distinct keys that are both in it, return their lowest common ancestor: the deepest node whose subtree contains both. A node's subtree includes…
Kth smallest element in a BSTCodingGiven the root of a binary search tree and an integer k, return the k-th smallest value in it, ideally stopping the in-order walk as soon as you reach it.
Last asked Feb 2026
Range sum of a BSTCodingGiven the root of a binary search tree and a range low, high, return the sum of the values inside the range, skipping subtrees that cannot contain any. Variants reported: return…
Last asked Oct 2025
Closest binary search tree valueCodingGiven a binary search tree and a target number (possibly fractional), return the value in the tree closest to it, walking down one path from the root.
Last asked Jul 2025
Delete a node from a binary search treeCodingGiven the root of a binary search tree and a key, delete the node with that key and return the root, keeping it a valid BST. Handle the cases of a leaf, a node with one child, and…
Last asked Apr 2025
+2
Largest value shared by two BSTsCodingYou are given the roots of two binary search trees, a and b, holding integer values. Return the largest integer that appears in both trees. If the trees share no value, return -1…
Question types
Binary search tree interview questions · Land the Lab