Brief Python solution

  • 0
    class Solution(object):
        def sumOfLeftLeaves(self, root):
            :type root: TreeNode
            :rtype: int
            if not root:
                return 0
            if  root.left and not root.left.left and not root.left.right:
                return root.left.val+self.sumOfLeftLeaves(root.right)
            return self.sumOfLeftLeaves(root.right)+self.sumOfLeftLeaves(root.left)

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.