LeetCode 938.
Tags: LeetCode
package lc_938;
public class Solution {
int total;
public int rangeSumBST(TreeNode root, int low, int high) {
if (root == null) return 0;
if (root.val >= low && root.val <= high){
total += root.val;
}
rangeSumBST(root.left, low, high);
rangeSumBST(root.right, low, high);
return total;
}
}
Check out the description of this problem at LC 938.