Skip to content

Commit c63167c

Browse files
committed
87
1 parent 7b4952d commit c63167c

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

Day87/index.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/**
2+
* Definition for a binary tree node.
3+
* function TreeNode(val) {
4+
* this.val = val;
5+
* this.left = this.right = null;
6+
* }
7+
*/
8+
/**
9+
* @param {TreeNode} original
10+
* @param {TreeNode} cloned
11+
* @param {TreeNode} target
12+
* @return {TreeNode}
13+
*/
14+
15+
var getTargetCopy = function(o, c, target) {
16+
17+
18+
let q1 = [o];
19+
let q2 =[c];
20+
21+
while(q1.length){
22+
23+
let data1 = q1.shift();
24+
let data2 = q2.shift();
25+
26+
if(data1.val == target.val){
27+
return data2;
28+
}
29+
30+
if(data1.left){
31+
q1.push(data1.left);
32+
q2.push(data2.left)
33+
}
34+
35+
if(data1.right){
36+
q1.push(data1.right)
37+
q2.push(data2.right)
38+
}
39+
40+
}
41+
42+
return -1
43+
};

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,4 +192,6 @@ If you are loving solving problems in leetcode, please contact me to enjoy it to
192192

193193
|Day 85| [1640. Check Array Formation Through Concatenation](https://leetcode.com/problems/palindrome-permutation/) | [javascript]()|[:memo:](https://leetcode.com/problems/palindrome-permutation/)|Easy|
194194

195-
|Day 86| [426. Convert Binary Search Tree to Sorted Doubly Linked Lis](https://leetcode.com/problems/convert-binary-search-tree-to-sorted-doubly-linked-list/submissions/) | [javascript]()|[:memo:](https://leetcode.com/problems/convert-binary-search-tree-to-sorted-doubly-linked-list/submissions/)|Medium|
195+
|Day 86| [426. Convert Binary Search Tree to Sorted Doubly Linked List](https://leetcode.com/problems/convert-binary-search-tree-to-sorted-doubly-linked-list/submissions/) | [javascript]()|[:memo:](https://leetcode.com/problems/convert-binary-search-tree-to-sorted-doubly-linked-list/submissions/)|Medium|
196+
197+
|Day 87| [1379. Find a Corresponding Node of a Binary Tree in a Clone of That Tree](https://leetcode.com/problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree/) | [javascript]()|[:memo:](https://leetcode.com/problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree/)|Medium|

0 commit comments

Comments
 (0)