Maximum Level Sum of a Binary Tree
Given the root
of a binary tree, the level of its root is 1
, the level of its children is 2
, and so on.
Return the smallest level X
such that the sum of all the values of nodes at level X
is maximal.
Example 1:
Note:
The number of nodes in the given tree is between
1
and10^4
.-10^5 <= node.val <= 10^5
Last updated