直接对第一个链表打标记,第二个链表检查有没有标记就完了

JavaScript:

function FindFirstCommonNode(pHead1, pHead2)
{
  let node1 = pHead1
  while(node1){
    node1.first = true
    node1 = node1.next
  }
  let node2 = pHead2
  while(node2){
    if(node2.first){
      return node2
    }
    node2 = node2.next
  }
}