@@ -0,0 +1,1863 @@
+%22%22%22%0AQuestion:%0A    Binary Tree Level Order Traversal II%0A%0A    Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root).%0A%0A    For example:%0A%0A    Given binary tree %7B3,9,20,#,#,15,7%7D,%0A        3%0A       / %5C%0A      9  20%0A        /  %5C%0A       15   7%0A%0A    return its bottom-up level order traversal as:%0A    %5B%0A      %5B15,7%5D,%0A      %5B9,20%5D,%0A      %5B3%5D%0A    %5D%0A%0A    confused what %22%7B1,#,2,3%7D%22 means? %3E read more on how binary tree is serialized on OJ.%0A%0APerformance:%0A    1. Total Accepted: 54938 Total Submissions: 174631 Difficulty: Easy%0A    2. Your runtime beats 91.80%25 of python submissions.%0A%22%22%22%0A%0A%0A# Definition for a binary tree node.%0Aclass TreeNode(object):%0A    def __init__(self, x):%0A        self.val = x%0A        self.left = None%0A        self.right = None%0A%0A    def __repr__(self):%0A        return %22%3CTreeNode#%7B%7D%3E%22.format(self.val)%0A        # return %22%3CTreeNode#%7B%7D left:%7B%7D, right:%7B%7D%3E%22.format(self.val, self.left, self.right)%0A%0A%0Aclass Solution(object):%0A    def levelOrderBottom(self, root):%0A        %22%22%22%0A        :type root: TreeNode%0A        :rtype: List%5BList%5Bint%5D%5D%0A        %22%22%22%0A        if root is None:%0A            return %5B%5D%0A%0A        curr_level_nodes = %5Broot%5D%0A        result = %5B%5D%0A%0A        while curr_level_nodes:%0A            result.insert(0, map(lambda n: n.val, curr_level_nodes))%0A%0A            tmp = %5B%5D%0A            for node in curr_level_nodes:%0A                if node.left:%0A                    tmp.append(node.left)%0A                if node.right:%0A                    tmp.append(node.right)%0A            curr_level_nodes = tmp%0A%0A        return result%0A%0A%0Al3 = TreeNode(3)%0Al9 = TreeNode(9)%0Al20 = TreeNode(20)%0Al15 = TreeNode(15)%0Al7 = TreeNode(7)%0Al3.left = l9%0Al3.right = l20%0Al20.left = l15%0Al20.right = l7%0A%0Al_expect = %5B%0A    %5B15, 7%5D,%0A    %5B9, 20%5D,%0A    %5B3%5D,%0A%5D%0A%0Aassert Solution().levelOrderBottom(l3) == l_expect%0A

Add 107-binary-tree-level-order-traversal-ii.py