
Problem Statement:
Given pointers to the head nodes of 2 linked lists that merge together at some point, find the Node where the two lists merge. It is guaranteed that the two head Nodes will be different, and neither will be NULL.
Problem:
Sample Code:
def findMergeNode(head1, head2):
p1=head1
p2=head2
while 1:
if p1==p2:
break
p1=p1.next
p2=p2.next
if p1==None:
p1=head2
if p2==None:
p2=head1
return p1.data
Linear Linked List in detail
Part-1.
Part-2.
Part-3.
Part-4.
0 Comments