Skip to content

Commit ccc4acd

Browse files
authored
Merge pull request careermonk#12 from shanmukht/master
currentSum was not calculated at each level.
2 parents 0064c6a + 3bae592 commit ccc4acd

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)