Skip to content

Latest commit

 

History

History

1161.Maximum-Level-Sum-of-a-Binary-Tree

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

[!WARNING|style:flat] This question is temporarily unanswered if you have good ideas. Welcome to Create Pull Request PR

Description

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:

Input: root = [1,7,0,7,-8,null,null]
Output: 2
Explanation: 
Level 1 sum = 1.
Level 2 sum = 7 + 0 = 7.
Level 3 sum = 7 + -8 = -1.
So we return the level with the maximum sum which is level 2.

Link to question: https://leetcode.com/problems/maximum-level-sum-of-a-binary-tree/

题意

...

题解

思路1

... Maximum Level Sum of a Binary Tree

结语

如果你同我一样热爱数据结构、算法、LeetCode,可以关注我 GitHub 上的 LeetCode 题解:awesome-golang-algorithm