Leetcode in Java && Oracle
419 subscribers
8 photos
397 files
400 links
Second channel: @codeforces_java

Let's Develop Together!
Download Telegram
image_2021-11-17_11-35-49.png
39.3 KB
#N160. Intersection of Two Linked Lists
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;

}
}