Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

two linked list intersection

public Node GetIntersectionNode(Node headA, Node headB) 
{
    if(headA ==null || headB==null)
    {
        return null; 
    }
    var a = headA; 
    var b = headB; 

    while(a != b)
    {
        a = a == null ? headB : a.next;
        b = b == null ? headA : b.next;
    }
    return a;
}
 
PREVIOUS NEXT
Tagged: #linked #list #intersection
ADD COMMENT
Topic
Name
1+5 =