← Questions

Range sum of a BST

0
MetaCodingLast asked Oct 2025

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?

Write and test your solution herePython in your browser, the question's tests level by level, saved for you.Sign in to start coding