Find a Corresponding Node of a Binary Tree in a Clone of That Tree LeetCode solution in C++

1
class Solution {
2
public:
3
TreeNode *getTargetCopy(TreeNode *original, TreeNode *cloned, TreeNode *target) {
4
if (original == target || original == NULL) return cloned;
5
TreeNode *found_left = getTargetCopy(original->left, cloned->left, target);
6
TreeNode *found_right = getTargetCopy(original->right, cloned->right, target);
7
if (found_left)
8
return found_left;
9
else
10
return found_right;
11
}
12
};

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0