Skip to content

Latest commit

 

History

History
12 lines (12 loc) · 418 Bytes

49.md

File metadata and controls

12 lines (12 loc) · 418 Bytes

Intersection of Two Linked List

LeetCode Link

    ListNode *getIntersectionNode(ListNode *headA, ListNode *headB) {
        ListNode* ptrA=headA;
        ListNode* ptrB=headB;
        while(ptrA!=ptrB){
            ptrA=(ptrA!=nullptr)?ptrA->next:headB;
            ptrB=(ptrB!=nullptr)?ptrB->next:headA;
        }
        return ptrA;
    }