@@ -0,0 +1,1559 @@
+# Time:  O(n)%0A# Space: O(h)%0A%0A# Given two binary trees and imagine that %0A# when you put one of them to cover the other,%0A# some nodes of the two trees are overlapped%0A# while the others are not.%0A#%0A# You need to merge them into a new binary tree.%0A# The merge rule is that if two nodes overlap,%0A# then sum node values up as the new value of the merged node.%0A# Otherwise, the NOT null node will be used as the node of new tree.%0A#%0A# Example 1:%0A# Input: %0A# %09Tree 1                     Tree 2                  %0A#           1                         2                             %0A#          / %5C                       / %5C                            %0A#         3   2                     1   3                        %0A#       /                           %5C   %5C                      %0A#       5                             4   7                  %0A# Output: %0A# Merged tree:%0A# %09     3%0A# %09    / %5C%0A# %09   4   5%0A# %09  / %5C   %5C %0A# %09 5   4   7%0A%09 %0A# Note: The merging process must start from the root nodes of both trees.%0A%0A# Definition for a binary tree node.%0A# class TreeNode(object):%0A#     def __init__(self, x):%0A#         self.val = x%0A#         self.left = None%0A#         self.right = None%0A%0Aclass Solution(object):%0A    def mergeTrees(self, t1, t2):%0A        %22%22%22%0A        :type t1: TreeNode%0A        :type t2: TreeNode%0A        :rtype: TreeNode%0A        %22%22%22%0A        if t1 is None:%0A            return t2%0A        if t2 is None:%0A            return t1%0A        t1.val += t2.val%0A        t1.left = mergeTrees(t1.left, t2.left)%0A        t1.right = mergeTrees(t1.right, t2.right)%0A        return t1%0A

Create merge-two-binary-trees.py