• Tutorials
  • DSA
  • Data Science
  • Web Tech
  • Courses
July 17, 2024 |1.5K 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/