Class Solution
java.lang.Object
g1301_1400.s1379_find_a_corresponding_node_of_a_binary_tree_in_a_clone_of_that_tree.Solution
1379 - Find a Corresponding Node of a Binary Tree in a Clone of That Tree.<p>Medium</p>
<p>Given two binary trees <code>original</code> and <code>cloned</code> and given a reference to a node <code>target</code> in the original tree.</p>
<p>The <code>cloned</code> tree is a <strong>copy of</strong> the <code>original</code> tree.</p>
<p>Return <em>a reference to the same node</em> in the <code>cloned</code> tree.</p>
<p><strong>Note</strong> that you are <strong>not allowed</strong> to change any of the two trees or the <code>target</code> node and the answer <strong>must be</strong> a reference to a node in the <code>cloned</code> tree.</p>
<p><strong>Example 1:</strong></p>
<p><img src="https://assets.leetcode.com/uploads/2020/02/21/e1.png" alt="" /></p>
<p><strong>Input:</strong> tree = [7,4,3,null,null,6,19], target = 3</p>
<p><strong>Output:</strong> 3</p>
<p><strong>Explanation:</strong> In all examples the original and cloned trees are shown. The target node is a green node from the original tree. The answer is the yellow node from the cloned tree.</p>
<p><strong>Example 2:</strong></p>
<p><img src="https://assets.leetcode.com/uploads/2020/02/21/e2.png" alt="" /></p>
<p><strong>Input:</strong> tree = [7], target = 7</p>
<p><strong>Output:</strong> 7</p>
<p><strong>Example 3:</strong></p>
<p><img src="https://assets.leetcode.com/uploads/2020/02/21/e3.png" alt="" /></p>
<p><strong>Input:</strong> tree = [8,null,6,null,5,null,4,null,3,null,2,null,1], target = 4</p>
<p><strong>Output:</strong> 4</p>
<p><strong>Constraints:</strong></p>
<ul>
<li>The number of nodes in the <code>tree</code> is in the range <code>[1, 10<sup>4</sup>]</code>.</li>
<li>The values of the nodes of the <code>tree</code> are unique.</li>
<li><code>target</code> node is a node from the <code>original</code> tree and is not <code>null</code>.</li>
</ul>
<p><strong>Follow up:</strong> Could you solve the problem if repeated values on the tree are allowed?</p>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal TreeNodegetTargetCopy(TreeNode original, TreeNode cloned, TreeNode target)
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
getTargetCopy
-