Back to course home
0% completed
Vote For New Content
Solution: Find Largest Value in Each Tree Row
Problem Statement
Given the root
of a binary tree, return an array containing the largest value in each row of the tree (0-indexed).
Examples
Example 1
- Input: root = [1, 2, 3, 4, 5, null, 6]
- Expected Output: [1, 3, 6]
- Justification:
- The first row contains1
. The largest value is1
. - The second row has2
and3
, and the largest is3
. - The third row has4
,5
, and6
, and the largest is6
.
Example 2
- Input: root = [7, 4, 8, 2, 5, null, 9, null, 3]
.....
.....
.....
Like the course? Get enrolled and start learning!
On this page