leetcode404: Sum of Left Leaves
来源:互联网 发布:手机号码拦截软件 编辑:程序博客网 时间:2024/06/03 19:55
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.
public int sumOfLeftLeaves(TreeNode root) {if (root == null)return 0;if (root.left != null && root.left.left == null && root.left.right == null)return root.left.val + sumOfLeftLeaves(root.right);return sumOfLeftLeaves(root.left) + sumOfLeftLeaves(root.right);}
0 0
- leetcode404: Sum of Left Leaves
- leetcode404. Sum of Left Leaves
- Leetcode404. 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
- [BZOJ2539][Ctsc2000]丘比特的烦恼(KM+计算几何)
- java学习之:复写equals方法
- 其他类型转化为json
- 基础排序算法-快速排序
- PAT 1002. A+B for Polynomials (25)
- leetcode404: Sum of Left Leaves
- 初级-(练习用)挑7
- (DUP!) ping现象
- python numpy array 与matrix 乘方
- Going Deeper with Convolutions学习笔记
- java学习之:Iterable与Iterator的区别
- STL中map,multimap,set,multiset,unordered_map,unordered_multimap,unordered_set,unordered_multiset的实现方
- 数据库范式
- Hadoop优化与调整