Merge Point of Two Lists

how to create a link list in which
one of the linked list got linked into the second list,

I am getting problem in creating two linklist in which one of node point to another node of second link list…

this is how you will do it:
step1: you can see from input that the two arrays can be seen as:
array1: x+y
array2: z+y
as both arrays has common y after intersection.
we need to find first point of y. if we get that, we will get our solution, you can create intersecting linked list also when you get that point. that point will be end node while creating second linked list.
step2. find l1, l2 are lengths of arrays.
case1. l1>l2, create two pointers, ptr1 points to (x-z+1)th index of array1, ptr2 points to 0th index of 2nd array. start moving both ptrs simultaneously, until you get first match.
say x is first index where array1[x] = array2[x]… then check if array1[x+i] = array2[x+i] for all further indices. if it happens then that is our point.
case2. if l2>l1, ptr2 should be ahead initially, everything else will be same as case1.

thanks

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.