class Solution: def sumOfLeftLeaves(self, root: TreeNode) -> int: if not root: return 0 if root and root.left and not root.left.left and not root.left.right: return root.left.val+self.sumOfLeftLeaves(root.right) return self.sumOfLeftLeaves(root.left) + self.sumOfLeftLeaves(root.right)
When execution: 44 ms, beat the 79.85% of users in all python3 submission
Memory consumption: 14.2 MB, beat the 5.22% of users in all python3 submission
——2019.11.20