标签:
#-*- coding: UTF-8 -*-
# Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution(object):
def dfs(self,root,isLeft):
if root==None:return 0
if(root.left==None and root.right==None and isLeft==True):return root.val
return self.dfs(root.left,True)+self.dfs(root.right,False)
def sumOfLeftLeaves(self, root):
return self.dfs(root,False)
【leetcode?python】 Sum of Left Leaves
标签:
原文地址:http://www.cnblogs.com/kwangeline/p/5953718.html