题解 | #最长不含重复字符的子字符串#
两个链表的第一个公共结点
http://www.nowcoder.com/practice/6ab1d9a29e88450685099d45c9e31e46
还有一种找最小公倍数的做法
/*function ListNode(x){
this.val = x;
this.next = null;
}*/
function FindFirstCommonNode(l1, l2)
{
if (!l1 || !l2) return null;
let set = new Set();
let p1 = l1;
let p2 = l2;
while (p1) {
set.add(p1);
p1 = p1.next;
}
while(p2) {
// if we find node from p2 that is in our set, then return the node
if (set.has(p2)) return p2;
p2 = p2.next;
}
return null;
}
module.exports = {
FindFirstCommonNode : FindFirstCommonNode
};