January 07, 2025 |1.6K Views

    Find maximum level sum in Binary Tree

      Share   Like
    Description
    Discussion

    Given a Binary Tree having positive and negative nodes, the task is to find the maximum sum level in it.

    Examples:

    Input :               4
                       /   \
                      2    -5
                     / \    /\
                   -1   3 -2  6
    Output: 6
    Explanation :
    Sum of all nodes of 0'th level is 4
    Sum of all nodes of 1'th level is -3
    Sum of all nodes of 0'th level is 6
    Hence maximum sum is 6

    Find maximum level sum in Binary Tree: https://www.geeksforgeeks.org/find-level-maximum-sum-binary-tree/