@sandeep notice that solution given on the given link doesn't satisfy the conditions given in the above question.
@sharad Both lists may have duplicate values. So in this case it will better to hash the address of node instead of values. One other way is to maintain a flag in each of the node. In the begining flag will be 0 for all the items in both list. While traversing the first list, set the flags to 1. While traversing the seconds list,look for the item for which flag has been set. But this will also take additional o(n) space. I was thinking in line of reversing the first list while traversing it (it will use recursion). However, I couldn't make it work. Any thoughts? On Oct 10, 3:02 am, sandeep jain <[email protected]> wrote: > Here is one solutionhttp://geeksforgeeks.org/?p=2405 > > On Fri, Oct 9, 2009 at 9:00 AM, sharad kumar <[email protected]>wrote: > > > space comp O(n) > > time o(2n) both in terms of worst case > > > On Fri, Oct 9, 2009 at 8:46 PM, ankur aggarwal > > <[email protected]>wrote: > > >> @sharad > > >> wat about space ?? > >> extra space ? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
