
package com.walegarrett.offer;
/**
* @Author WaleGarrett
* @Date 2021/2/9 19:08
*/
public class Offer_52 {
public ListNode getIntersectionNode(ListNode headA, ListNode headB) {
ListNode nowA = headA;
ListNode nowB = headB;
while(nowA != nowB){
if(nowA == null){
nowA = headB;
}else nowA = nowA.next;
if(nowB == null)
nowB = headA;
else nowB = nowB.next;
}
return nowA;
}
}
剑指 Offer 52. 两个链表的第一个公共节点 + 链表 + 第一个公共结点 + 双指针
原文:https://www.cnblogs.com/GarrettWale/p/14394078.html