Skip to content

Commit 1804364

Browse files
committed
938
1 parent 9368388 commit 1804364

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

E_938_RangeSumofBST.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class Solution {
2+
public int rangeSumBST(TreeNode root, int low, int high) {
3+
if(root==null) return 0;
4+
if(root.val> high)
5+
return rangeSumBST(root.left, low, high);
6+
if(root.val< low)
7+
return rangeSumBST(root.right, low, high);
8+
return root.val+rangeSumBST(root.left,low,high)+rangeSumBST(root.right, low, high);
9+
}
10+
}

0 commit comments

Comments
 (0)