本文主要是介绍1302. Deepest Leaves Sum,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
Problem
Given a binary tree, return the sum of values of its deepest leaves.
Example
Input: root = [1,2,3,4,5,null,6,7,null,null,null,null,8]
Output: 15
Solution
2020-3-9,层序遍历。
/*** Definition for a binary tree node.* struct TreeNode {* int val;* TreeNode *left;* TreeNode *right;* TreeNode(int x) : val(x), left(NULL), right(NULL) {}* };*/
class Solution {
public:int deepestLeavesSum(TreeNode* root) {if(!root
这篇关于1302. Deepest Leaves Sum的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!