consider the length of list1 is 7(ie m) and length of list2 is 5 (ie n)..now
find (m-n) ie 7-5=2..since length of list2 is smaller than list1,,have a
pointer pointing to the head of the list2 and move that pointer (m-n)
positions ie (here 2 positions)..now have a pointer pointing to the head of
list1 and also list2's pointer points to 3rd node(since we have moved 2
nodes)..now compare both the list's data part..if they are different,,move
both de pointer's by one node..continue doing this till you reach the
intersection point..if they both have same data,,that is the intersection
point

On Thu, Sep 29, 2011 at 10:38 PM, Ankuj Gupta <[email protected]> wrote:

> There are two linked list of length m and n. There is some common data
> at the end of both. Find the starting position in both the linked
> list. I could suggest two methods
>
> 1) Reverse the list and check .
> 2) Use recursion to go to the last element and move back from there.
>
> Is there any other way ?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>


-- 
*prasanth*

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to