Skip to content

Commit 7e390a4

Browse files
committed
Create find_merge_point.js
1 parent 605c733 commit 7e390a4

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
function findMergeNode(headA, headB) {
2+
let arr = []
3+
while (a || b) {
4+
if (a && arr.find(n => n === a)) return a.data;
5+
else if(a) {
6+
arr.push(a)
7+
a = a.next;
8+
}
9+
if (b && arr.find(n => n === b)) return b.data;
10+
else if (b) {
11+
arr.push(b);
12+
b = b.next;
13+
}
14+
}
15+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy