404. Sum of Left Leaves
来源:互联网 发布:感染少女数据 编辑:程序博客网 时间:2024/04/30 21:22
Find the sum of all left leaves in a given binary tree.
Example:
3 / \ 9 20 / \ 15 7There are two left leaves in the binary tree, with values 9 and 15 respectively. Return 24.
/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */public class Solution { public int sumOfLeftLeaves(TreeNode root) { if (root == null)return 0;if (root.left != null && root.left.right == null&& root.left.left == null) {return root.left.val + sumOfLeftLeaves(root.right);}return sumOfLeftLeaves(root.left) + sumOfLeftLeaves(root.right); }}
0 0
- 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
- 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
- 404. Sum of Left Leaves
- 404. Sum of Left Leaves
- 404. Sum of Left Leaves
- 404. Sum of Left Leaves
- Linux鼠标选定内容后自动弹出 ^C 的解决办法
- android程序一个注册,然后到设置兴趣爱好,出生日期,然后把所有信息显示在另一个页面的程序
- Cocos2D-X学习4:几个重要的类:Node、Director、Scene、Layer
- 文件系统---stat函数
- STM32 USART库函数介绍2
- 404. Sum of Left Leaves
- Shader山下(五)使用表面着色器实现透明材质
- JS中基本函数,字符串函数,日期函数
- 在ubuntu16.04(cpu)上安装tensorflow
- iOS开发运行时机制介绍
- 今日学习——两数值内容进行交换及其优化
- HDU 5898 数位DP
- 准确率(Precision)、召回率(Recall)以及综合评价指标(F1 Measure )
- sleep和wait的区别