Given a binary tree, find the largest value in each level.
Example 1
Input: root[] = [1, 2, 3]
Output: [1, 3]
Explanation: First traverse the first level then second level.
Example 2
Input: root = [3,9,20,N,N,15,7]
Output: [3, 20, 15]
Explanation: Traverse the tree level wise, first traverse the first level, then second and so on.
Approach, complexity and clean code in every language. Sign in to unlock the editorial.
Your submissions, results and runtime history live here. Sign in to start your streak.
1 2 3
1 3
3 9 20 N N 15 7
3 20 15