Problem Statement
Range Sum of BST (LeetCode 938) asks you to compute the sum of all node values in a binary search tree (BST) that fall within an inclusive range [low, high], given the tree's root node. This Meta interview problem leverages BST properties for efficient traversal with DFS, focusing on tree and binary tree navigation.[1][2]
Input/Output Format
Input: TreeNode root, int low, int high.
Output: int (sum of node values where low ≤ node.val ≤ high).
The TreeNode class defines: val (integer), left, right pointers.[2][6]
Examples
Example 1:
Tree: root=10, left=5 (left=3, right=7), right=15, right=18. low=7, high=15.
Nodes in range: 10, 7, 15 → Output: 32.[3][1]
Example 2:
Tree: root=4 (left=2 right=5 left=1 right=3), right=6. low=2, high=4.
Nodes in range: 4, 3, 2 → Output: 9.[2]
Example 3 (variant context):
Tree with nodes 6,7,10 in range → Output: 23.[3]
Constraints