1class Solution {
2 public int rangeSumBST(TreeNode root, int low, int high) {
3 if(root == null)
4 return 0;
5
6 if(root.val > high)
7 {
8 return rangeSumBST(root.left,low,high);
9 }
10 else if(root.val < low)
11 {
12 return rangeSumBST(root.right,low,high);
13 }
14 else
15 {
16 return root.val + rangeSumBST(root.left,low,high) + rangeSumBST(root.right,low,high);
17 }
18
19}
20}