leetcode_Sum of Left Leaves
来源:互联网 发布:java运维面试题 编辑:程序博客网 时间:2024/06/07 13:20
Find the sum of all left leaves in a given binary tree.
3
/ \
9 20
/ \
15 7
There are two left leaves in the binary tree, with values 9 and 15 respectively. Return 24.
class Solution {public: int sumOfLeftLeaves(TreeNode* root) { int result = 0; if(root) { if(root->left && root->left->left == NULL && root->left->right == NULL) { result += root->left->val; } result += sumOfLeftLeaves(root->left)+sumOfLeftLeaves(root->right); } return result; }};
0 0
- leetcode_Sum of Left Leaves
- Sum of Left Leaves
- Sum of Left Leaves
- Sum of Left Leaves
- Sum of Left Leaves
- Sum of Left Leaves
- Sum of Left Leaves
- Sum of Left Leaves
- Sum of Left Leaves
- Sum of Left Leaves
- Sum of Left Leaves
- 404. Sum of Left Leaves
- 404. Sum of Left Leaves
- 404. Sum of Left Leaves
- 404. Sum of Left Leaves
- 404. Sum of Left Leaves
- 404. Sum of Left Leaves
- 404. Sum of Left Leaves
- Java中的Socket通信(TCP)
- 【UOJ 246】【UER #7】套路
- 剑指offer-调整数组顺序使奇数位于偶数前面
- leetcode13: Roman to Integer
- TCMalloc的使用与源码剖析之三---------TCMalloc的内存分配的主要层次
- leetcode_Sum of Left Leaves
- OpenCV - 训练分类器
- 移动 Ubuntu16.04 桌面左侧的启动器到屏幕底部
- ajax提交ckeditor内容,以及处理特殊字符
- 各种AJAX方法的使用比较
- appium记录--如何获取应用的包名以及Activity的方法
- Unity中内嵌网页插件 UniWebView 2.8使用
- SEO概览
- 单张图片自适应