/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class Solution {
private:
TreeNode *root = NULL;
public:
void pre(TreeNode* cloned, TreeNode* target) {
if(cloned) {
if(cloned->val==target->val) root=cloned;
else {
pre(cloned->left,target);
pre(cloned->right,target);
}
}
}
TreeNode* getTargetCopy(TreeNode* original, TreeNode* cloned, TreeNode* target) {
pre(cloned, target);
return root;
}
};