Grokking 75: Top Coding Interview Questions
Ask Author
Back to course home

0% completed

Vote For New Content
Find Largest Value in Each Tree Row (medium)
On this page

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 contains 1. The largest value is 1. - The second row has 2 and 3, and the largest is 3. - The third row has 4, 5, and 6, and the largest is 6.

Example 2

  • Input: root = [7, 4, 8, 2, 5, null, 9, null, 3]

.....

.....

.....

Like the course? Get enrolled and start learning!

On this page