Problem 2476 · Medium

Closest Nodes Queries in a Binary Search Tree

Read the tree values in sorted order, then binary search for the largest value at most each query and the smallest value at least it.

Open the interactive visualisation