Tap here to switch tabs
Problem
Submissions

Problem: Find Largest Value in Each Tree Row

med
30 min
Try to solve the Find Largest Value in Each Tree Row problem.

Statement

Given the root node root of a binary tree, return an array where the element at index ii is the maximum value among all nodes on level ii of the tree, with the root considered level 00. If the tree is empty, return an empty array.

Constraints:

  • The number of nodes in the tree is in the range [0,104][0, 10^4].

  • −231≤-2^{31} \leq Node.val ≤231−1\leq 2^{31} - 1

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Find Largest Value in Each Tree Row

med
30 min
Try to solve the Find Largest Value in Each Tree Row problem.

Statement

Given the root node root of a binary tree, return an array where the element at index ii is the maximum value among all nodes on level ii of the tree, with the root considered level 00. If the tree is empty, return an empty array.

Constraints:

  • The number of nodes in the tree is in the range [0,104][0, 10^4].

  • −231≤-2^{31} \leq Node.val ≤231−1\leq 2^{31} - 1