sort both linked lists using non-recursive merge sort: Time: O(nlogn),
Space: O(1)
Then
while both lists are not null
loop
  if list1->data == list2->data then
      print/store list1->data
      move list1 pointer one node further
      move list2 pointer pne node further
 else if list1->data < list2->data then
     move list1 pointer one node further
 else
    move list2 pointer one node further
done


On Jan 12, 2:23 am, Aniket <aniket...@gmail.com> wrote:
> Find the intersection of two unsorted singly linked list in O(1) space
> and less than O(n^2) complexity.

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

Reply via email to