Range sum of a BST

0
Remix

Given 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 the average of those values instead; and if the tree is very large and the range changes often, how would you answer many queries faster?

MetaTechnical phone screenLast asked Oct 2025
No answer yet. Write the first one; the best answer gets endorsed.