Skip to content

Commit 224e76c

Browse files
committed
Fix error in RangeSumOfBST solution
1 parent f17e07a commit 224e76c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/main/java/by/andd3dfx/tree/RangeSumOfBST.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ public static int rangeSumBST_usingQueue(TreeNode root, int low, int high) {
3434
var sum = 0;
3535
while (!queue.isEmpty()) {
3636
var element = queue.pop();
37-
if (element.left != null && root.val >= low) {
37+
if (element.left != null && element.val >= low) {
3838
queue.add(element.left);
3939
}
40-
if (element.right != null && root.val <= high) {
40+
if (element.right != null && element.val <= high) {
4141
queue.add(element.right);
4242
}
4343
if (low <= element.val && element.val <= high) {

0 commit comments

Comments
 (0)