Skip to content

Commit 3bae592

Browse files
authored
currentSum was not calculated at each level.
1 parent 4ad6d93 commit 3bae592

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/chapter06trees/FindLevelwithMaxSum.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public int findLevelwithMaxSum(BinaryTreeNode root) {
2929
while (!q.isEmpty()) {
3030
BinaryTreeNode tmp = q.poll();
3131
if (tmp != null) {
32+
currentSum += tmp.getData();
3233
if (tmp.getLeft() != null)
3334
q.offer(tmp.getLeft());
3435
if (tmp.right != null)

0 commit comments

Comments
 (0)