"""Leetcode 404. Sum of Left Leaves
Easy

URL: https://leetcode.com/problems/sum-of-left-leaves/

Find the sum of all left leaves in a given binary tree.

Example:
    3
   / \
  9  20
    /  \
   15   7

There are two left leaves in the binary tree, with values 9 and 15 respectively. 
Return 24.
"""

# 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 sumOfLeftLeaves(self, root):
        """
        :type root: TreeNode
        :rtype: int
        """
        pass


def main():
    pass


if __name__ == '__main__':
    main()

@@ -472,16 +472,21 @@
 Solution
+Recur
 (object)
@@ -589,55 +589,665 @@
 int%0A
-        %22%22%22%0A        pass%0A%0A%0Adef main():%0A    pass
+%0A        Time complexity: O(n).%0A        Space complexity: O(logn) for balanced tree; O(n) for singly linked list.%0A        %22%22%22%0A        # Base case.%0A        if not root:%0A            return 0%0A%0A        if root.left and not root.left.left and not root.left.right:%0A            return root.left.val + self.sumOfLeftLeaves(root.right)%0A        else:%0A            return self.sumOfLeftLeaves(root.left) + self.sumOfLeftLeaves(root.right)%0A%0A%0Adef main():%0A    # Output: 20.%0A    root = TreeNode(3)%0A    root.left = TreeNode(9)%0A    root.right = TreeNode(20)%0A    root.right.left = TreeNode(15)%0A    root.right.right = TreeNode(7)%0A    print SolutionRecur().sumOfLeftLeaves(root)
 %0A%0A%0Ai

Complete recur sol