404. Sum of Left Leaves
来源:互联网 发布:ip与mac绑定有什么缺点 编辑:程序博客网 时间:2024/05/21 02:50
class Solution(object): def sumOfLeftLeaves(self, root): """ :type root: TreeNode :rtype: int """ # def findleft(root): # if root: # if root.left != None: # self.sum += findleft(root.left) # if root.right != None: # self.sum += findleft(root.right) # if not root.left and not root.right: # return root.val # self.sum = 0 # findleft(root) # return self.sum if(root == None): return 0 ans = 0; if(root.left != None) : if root.left.left == None and root.left.right == None: ans += root.left.val; else: ans += self.sumOfLeftLeaves(root.left) ans += self.sumOfLeftLeaves(root.right) return ans;
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
- 51nod 1405 树的距离之和
- Android VR Player(全景视频播放器) [2]:开发说明
- 第七章、字符串
- php上传常见文件类型对应的$_FILES["file"]["type"]。
- Java概念性问题4
- 404. Sum of Left Leaves
- 开发、调试、版本管理、包管理工具、压缩混淆工具、测试(angularjs)
- python读取txt解决中文乱码问题
- python安装mysqldb
- 欢迎使用CSDN-markdown编辑器
- linux指南之六
- 步伐
- 分布式配置管理平台Jconf设计与实现(一)
- leetcode解题系列:Two Sum