题解 | #两个链表的第一个公共结点#
两个链表的第一个公共结点
https://www.nowcoder.com/practice/6ab1d9a29e88450685099d45c9e31e46
# class ListNode: # def __init__(self, x): # self.val = x # self.next = None # # # @param pHead1 ListNode类 # @param pHead2 ListNode类 # @return ListNode类 # class Solution: def FindFirstCommonNode(self, pHead1, pHead2): l1 = pHead1 l2 = pHead2 while l1 != l2: l1 = l1.next if l1 else pHead2 l2 = l2.next if l2 else pHead1 return l1