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.
Be the first one to answer
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