Skip to content

Commit

Permalink
938
Browse files Browse the repository at this point in the history
  • Loading branch information
isinsuarici committed Jan 7, 2022
1 parent 9368388 commit 1804364
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions E_938_RangeSumofBST.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class Solution {
public int rangeSumBST(TreeNode root, int low, int high) {
if(root==null) return 0;
if(root.val> high)
return rangeSumBST(root.left, low, high);
if(root.val< low)
return rangeSumBST(root.right, low, high);
return root.val+rangeSumBST(root.left,low,high)+rangeSumBST(root.right, low, high);
}
}

0 comments on commit 1804364

Please sign in to comment.