Problem: Range Sum of BST
Explore how to calculate the sum of all node values within a given range in a binary search tree. Learn to apply the BST property for pruning subtrees and use a recursive approach to optimize traversal, improving efficiency in both time and space.
We'll cover the following...
We'll cover the following...
Statement
You are given the root of a binary search tree (BST) along with two integers low and high. Compute and return the sum of all node values that fall within the inclusive range [low, high].
Note: All node values in the BST are unique.
Constraints:
The number of nodes in the tree is in the range
. ...