Skip to content

Commit 276b91b

Browse files
committed
1379. Find a Corresponding Node of a Binary Tree in a Clone of That Tree
1 parent 3d52f71 commit 276b91b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Runtime: 712 ms
2+
// Memory Usage: 166 MB
3+
class Solution {
4+
public:
5+
TreeNode* getTargetCopy(TreeNode* original, TreeNode* cloned, TreeNode* target) {
6+
if(!original) return NULL;
7+
if(original == target) return cloned;
8+
TreeNode* l = getTargetCopy(original->left, cloned->left, target);
9+
if(l != NULL) return l;
10+
return getTargetCopy(original->right, cloned->right, target);
11+
}
12+
};

0 commit comments

Comments
 (0)