Tap here to switch tabs
Problem
Submissions

Problem: Maximum Level Sum of a Binary Tree

Try to solve the Maximum Level Sum of a Binary Tree problem.

Statement

Given the root of a binary tree, the root is located at level 11, its children are located at level 22, and subsequent generations continue incrementally.

Return the smallest level xx such that the sum of all node values at level xx is maximal.

Constraints:

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

  • −105≤-10^5 \leq Node.val ≤105\leq 10^5

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximum Level Sum of a Binary Tree

Try to solve the Maximum Level Sum of a Binary Tree problem.

Statement

Given the root of a binary tree, the root is located at level 11, its children are located at level 22, and subsequent generations continue incrementally.

Return the smallest level xx such that the sum of all node values at level xx is maximal.

Constraints:

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

  • −105≤-10^5 \leq Node.val ≤105\leq 10^5