Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 276b91b

Browse files
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)

AltStyle によって変換されたページ (->オリジナル) /