
Maximum Level Sum in Binary Tree Problem Statement
Given an arbitrary binary tree consisting of N nodes, where each node is associated with a certain value, your task is to find the maximum sum for any level in the tree.
Example:
Input:
1
1 2 3 4 -1 5 6 -1 7 -1 -1 -1 -1 -1 -1
Output:
13
Explanation:
The maximum level sum is 13 for level 3 from node values (5+6+2) or level 1 (17-4).
Constraints:
1 ≤ T ≤ 100
1 ≤ N ≤ 3000
-1000 ≤ data ≤ 1000
- data ≠ -1
Note:
- The input for a tree is provided as a single line of integers separated by spaces, representing level order traversal where '-1' denotes a null node.

AnswerBot
14d

Find the maximum sum for any level in a binary tree.
Traverse the binary tree level by level and calculate the sum for each level.
Keep track of the maximum sum encountered so far.
Return the maximum sum...read more

Help your peers!
Add answer anonymously...
Top Snapdeal Software Engineer interview questions & answers
Popular interview questions of Software Engineer
Top HR questions asked in Snapdeal Software Engineer
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app