Easy to understand Python Solution


  • 0
    J
        res = 0
        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:
                    self.res += root.left.val
            self.sumOfLeftLeaves(root.left)
            self.sumOfLeftLeaves(root.right)
            return self.res

Log in to reply
 

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