Closest Nodes Queries in a Binary Search Tree

Medium · Binary Search Trees · about 20 minutes

Asked at Google, Amazon, Microsoft.

Given a BST and an array queries, return for each query q the pair [mini, maxi]: the largest value ≤ q and the smallest value ≥ q in the tree (-1 if none exists).

Related guides