class Solution(object):
def sumOfLeftLeaves(self, root):
"""
:type root: TreeNode
:rtype: int
"""
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;
转载请注明原文地址: https://www.6miu.com/read-44455.html