image_2021-11-17_11-35-49.png
39.3 KB
#N160. Intersection of Two Linked Lists
problem link
#solution
problem link
#solution
public class Solution {
public ListNode getIntersectionNode(ListNode headA, ListNode headB) {
ListNode currA=headA, currB=headB;
while(currA!=currB){
if(currA==null)
currA=headB;
else
currA=currA.next;
if(currB==null)
currB=headA;
else
currB=currB.next;
}
return currA;
}
}