LeetCode 404 Sum of Left Leaves
来源:互联网 发布:免费刷手机流量软件 编辑:程序博客网 时间:2024/06/05 06:21
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;int leaf = 0;if (root.left != null && root.left.right == null && root.left.left == null)leaf = root.left.val;return leaf + sumOfLeftLeaves(root.left) + sumOfLeftLeaves(root.right);}
0 0
- LeetCode 404 Sum of Left Leaves
- [LeetCode-404]Sum of Left Leaves(java)
- Leetcode 404 Sum of Left Leaves
- LeetCode[404] Sum of Left Leaves
- LeetCode #404: Sum of Left Leaves
- LeetCode 404 Sum of Left Leaves (DFS)
- leetcode 404 Sum of Left Leaves
- LeetCode #404 - Sum of Left Leaves - Easy
- leetcode 404 Sum of Left Leaves C++
- leetcode-404-Sum of Left Leaves
- leetcode 404 Sum of Left Leaves
- [Leetcode] #404 Sum of Left Leaves
- Leetcode #404 Sum of Left Leaves
- LeetCode 404:Sum of Left Leaves
- LeetCode 404 Sum of Left Leaves
- Sum of Left Leaves ---LeetCode
- Leetcode Sum of Left Leaves
- LEETCODE--Sum of Left Leaves
- HBase中Filter总结
- java学习笔记一
- Leetcode-21. Merge Two Sorted Lists
- 【Python开发】Python PIL ImageDraw 和ImageFont模块学习
- ResearchWork
- LeetCode 404 Sum of Left Leaves
- hadoop下运行WordCout单词计数抛出错误
- [151023][枕]櫻之詩 在櫻花之森上飛舞[サクラノ诗-樱の森の上を舞う-]【日文硬盘版】[带全CG存档+攻略]
- Java:排序法(从大到小)和二分查找法(找某个值的索引号)
- 用flask开发个人博客(16)—— 表单类的使用
- PHP框架---配置加载类&&日志类
- 十种经典的排序算法C#实现(持续更新ing)
- MariaDB简单CURD实践
- 【框架】pinyin4j中文汉字转化为拼音