Leetcode 2476. Closest Nodes Queries in a Binary Search Tree
For each query value, return the floor (largest value ≤ query) and ceil (smallest value ≥ query) that exist in the given binary search tree, using -1 when no such value exists. With up to 1e5 nodes/queries, solve efficiently by exploiting BST order (per-query traversal) or by inorder-sorting the tree and binary searching the array.
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
Your account is free and you can post anonymously if you choose.