|
2 | 2 |
|
3 | 3 | import com.fishercoder.common.classes.TreeNode;
|
4 | 4 |
|
5 |
| -/** |
6 |
| - * 1379. Find a Corresponding Node of a Binary Tree in a Clone of That Tree |
7 |
| - * |
8 |
| - * Given two binary trees original and cloned and given a reference to a node target in the original tree. |
9 |
| - * The cloned tree is a copy of the original tree. |
10 |
| - * Return a reference to the same node in the cloned tree. |
11 |
| - * Note that you are not allowed to change any of the two trees or the target node and the answer must be a reference to a node in the cloned tree. |
12 |
| - * |
13 |
| - * Follow up: Solve the problem if repeated values on the tree are allowed. |
14 |
| - * |
15 |
| - * Example 1: |
16 |
| - * Input: tree = [7,4,3,null,null,6,19], target = 3 |
17 |
| - * Output: 3 |
18 |
| - * Explanation: 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. |
19 |
| - * |
20 |
| - * Example 2: |
21 |
| - * Input: tree = [7], target = 7 |
22 |
| - * Output: 7 |
23 |
| - * |
24 |
| - * Example 3: |
25 |
| - * Input: tree = [8,null,6,null,5,null,4,null,3,null,2,null,1], target = 4 |
26 |
| - * Output: 4 |
27 |
| - * |
28 |
| - * Example 4: |
29 |
| - * Input: tree = [1,2,3,4,5,6,7,8,9,10], target = 5 |
30 |
| - * Output: 5 |
31 |
| - * |
32 |
| - * Example 5: |
33 |
| - * Input: tree = [1,2,null,3], target = 2 |
34 |
| - * Output: 2 |
35 |
| - * |
36 |
| - * Constraints: |
37 |
| - * The number of nodes in the tree is in the range [1, 10^4]. |
38 |
| - * The values of the nodes of the tree are unique. |
39 |
| - * target node is a node from the original tree and is not null. |
40 |
| - * */ |
41 | 5 | public class _1379 {
|
42 | 6 | public static class Solution1 {
|
43 | 7 | public final TreeNode getTargetCopy(final TreeNode original, final TreeNode cloned, final TreeNode target) {
|
|
0 commit comments