题目标题

找出链表的第一个公共结点

参考解析
  1. class Solution:
  2. def getIntersectionNode(self, headA: ListNode, headB: ListNode) -> ListNode:
  3. node1, node2 = headA, headB
  4. while node1 != node2:
  5. node1 = node1.next if node1 else headB
  6. node2 = node2.next if node2 else headA
  7. return node1