2022-05-17 04:59:02 +0000 UTC
Find a Corresponding Node of a Binary Tree in a Clone of That Tree
Categories:
Links
Code
class Solution {
TreeNode ans;
public void inorder(TreeNode c,TreeNode target) {
if (c != null) {
inorder(c.left, target);
if (c.val == target.val) {
ans = c;
}
inorder(c.right, target);
}
}
public final TreeNode getTargetCopy(final TreeNode original, final TreeNode cloned, final TreeNode target)
{
inorder(cloned,target);
return ans;
}
}