I would suggest that you keep all the elements in one list. Then check if the list contains the value already(a HashSet would be a better option). If it does contain the value copy that element into the common list. Meanwhile carry on the procedure with HashMap it's just that you would not have to iterate through all the pairs.
I like to do problems like this in sorted order, a holdover from my days when the data was all on tape with sequential reads only. If you can copy the list data into TreeSets and not mind losing duplicates you might be in business. Yesterday I posted my old favorite Master-Update-Merge algorithm. I have a variation for any number of inputs instead of just two and even built it into a little utility so I never have to write it again. Let me know if that sounds interesting. [ June 28, 2007: Message edited by: Stan James ]
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Joined: May 04, 2007
Thanks for the reply. Now I got into a different situation
I have a list of Objects and I am trying to overide the equals method in my object class to check for equality..