Maximum Node Level
Easy Accuracy: 50.32% Submissions: 12746 Points: 2

Given a Binary tree. Find the level in binary tree which has the maximum number of nodes.

Example 1:

    /    \ 
   1      3
 /   \     \
4    6      8
Output: 2
Explanation: The level 2 with nodes 4,
6 and 8 is the level with maximum
number of nodes. 

Your Task:
You don't need to read input or print anything. Your task is to complete the function
 maxNodeLevel() that takes root node of the tree as input and returns an integer which is level of the tree with maximum nodes. The root is at level 0. If two or more levels have same number of maximum nodes , then return smallest level.

Expected Time Complexity: O(N).
Expected Auxiliary Space: O(N).

1<=Number of level<=10

to report an issue on this page.


We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?


All Submissions

My Submissions:

Login to access your submissions.

Maximum Node Level

Output Window