Skip to content

Commit 7efa748

Browse files
committed
tree
1 parent bf0b1ee commit 7efa748

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

938_range_sum_of_bst.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
object Solution {
2+
def rangeSumBST(root: TreeNode, L: Int, R: Int): Int = {
3+
if (root == null) 0
4+
else if (root.value < L) rangeSumBST(root.right, L, R)
5+
else if (root.value > R) rangeSumBST(root.left, L, R)
6+
else{
7+
root.value + rangeSumBST(root.right, L, R) + rangeSumBST(root.left, L, R)
8+
}
9+
}
10+
}

0 commit comments

Comments
 (0)