Created
January 2, 2021 11:10
-
-
Save bobfang1992/0ee1fd4448aa1e0d70841ddb823621d5 to your computer and use it in GitHub Desktop.
Leetcode 1379
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Definition for a binary tree node. | |
# class TreeNode: | |
# def __init__(self, x): | |
# self.val = x | |
# self.left = None | |
# self.right = None | |
class Solution: | |
def getTargetCopy(self, original: TreeNode, cloned: TreeNode, target: TreeNode) -> TreeNode: | |
val = target.val | |
def find(node): | |
if not node: | |
return | |
if node.val == val: | |
return node | |
return find(node.left) or find(node.right) | |
return find(cloned) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment