Skip to content

Instantly share code, notes, and snippets.

@bobfang1992
Created January 2, 2021 11:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bobfang1992/0ee1fd4448aa1e0d70841ddb823621d5 to your computer and use it in GitHub Desktop.
Save bobfang1992/0ee1fd4448aa1e0d70841ddb823621d5 to your computer and use it in GitHub Desktop.
Leetcode 1379
# 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