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;
}
}
手机扫一扫
移动阅读更方便
你可能感兴趣的文章