We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9368388 commit 1804364Copy full SHA for 1804364
E_938_RangeSumofBST.java
@@ -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