Question
Sum of Nodes in BST Range
You are given the root of a Binary Search Tree (BST) and two integers low and high.

Your task is to compute the sum of all node values that lie within the inclusive range [low, high].
Input
User Task
Since this is a functional problem, you do not need to handle input or output. Your task is to complete the function rangeSumBST(), which takes the root node,  and integers low and  high as the input parameter.

Custom Input
The first line of input contains an integer, N, representing the number of nodes in the tree.
The next line consists of space-separated integers denoting the level order traversal of the tree, where non-negative values represent node values, and -1 indicates a null node.
The third line of the input contains two integers low and high
Note: Once a node is marked as -1, no further information about its children is provided.
Output
Return the sum of values of all nodes with a value greater than or equal to low and lesser than or equal to high.
Example
Input:
6
5 3 6 2 4 -1 7
3 6

Output:
18
Explanation
Valid nodes in range [3, 6] are: 3, 4, 5, 6
Sum = 3 + 4 + 5 + 6 = 18

Input:
10
50 25 75 12 37 62 87 -1 -1 30 -1 60 70
30 61

Output:
177

Online