题解 | #两个链表的第一个公共结点#
两个链表的第一个公共结点
https://www.nowcoder.com/practice/6ab1d9a29e88450685099d45c9e31e46
/* 1. 主要思路就是如何让两个链表长度相等,利用 两链表长度加起来相等原理,实现,太妙了 function ListNode(x){ this.val = x; this.next = null; }*/ function FindFirstCommonNode(pHead1, pHead2) { // write code here let ta = pHead1 let tb = pHead2 while(ta !== tb){ ta = ta ? ta.next : pHead2 tb = tb ? tb.next : pHead1 } return ta } module.exports = { FindFirstCommonNode : FindFirstCommonNode };