题目:
题解:
class Solution:def sumOfLeftLeaves(self, root: TreeNode) -> int:if not root:return 0isLeafNode = lambda node: not node.left and not node.rightq = collections.deque([root])ans = 0while q:node = q.popleft()if node.left:if isLeafNode(node.left):ans += node.left.valelse:q.append(node.left)if node.right:if not isLeafNode(node.right):q.append(node.right)return ans