Closest Binary Search Tree Value II

Hard · Binary Search Trees · about 30 minutes

Asked at LinkedIn, Google, Meta, Amazon.

target is a real number. Pick the k values in the binary search tree that lie nearest to it and return them in any order. The tests guarantee a single correct set.

Related guides