easy to understand python solution

  • 0
    # 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 mergeTrees(self, t1, t2):
            :type t1: TreeNode
            :type t2: TreeNode
            :rtype: TreeNode
            if t1==None and t2==None:
                return None
            if t1==None and t2!=None:
                return t2
            if t1!=None and t2==None:
                return t1
            if t1!=None and t2!=None:
                return root

Log in to reply

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