Given a Binary Tree having positive and negative nodes. Find the maximum sum of a level in the given Binary Tree.
/ \ / \
-1 3 -2 6Output: 6Explanation :
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 2'th level is 6
Hence maximum sum is 6
/ \ \
4 5 8
6 7 Output : 17Explanation: Maximum sum is at level 2.
You dont need to read input or print anything. Complete the function maxLevelSum() which takes root node as input parameter and returns the maximum sum of any horizontal level in the given Binary Tree.
Expected Time Complexity: O(N) Expected Auxiliary Space: O(N)