I'm thinking about creating 2 list-like data structures to manipulate. I don't really care what the data type is -- use whichever you think is best for this problem:
The first "list" will be populated with a bunch of integers (They represent id_numbers from a db). This is the reference list.
The second list will also have a bunch of integers. Neither list is too big, 50 numbers or so.
I'd like an algorithm which looks through the 2nd list, and if it finds a number NOT in the first list, removes it from the 2nd list, and also eliminates duplicates in the second list.
Put another way, no numbers are allowed in the 2nd list UNLESS they exist in the first list, and no duplicate numbers are allowed in the 2nd list, either.
There may be duplicates in either list to begin with, but in the end the 2nd list must have only unique values.
So, if the first (reference) list has 7 5 6 2 3 4 4 1 56
and the second list has 2 3 4 75 33 6 4 2
then, in the end, the second list can only contain (order doesn't matter)
2 3 4 6
Sorry this is only worth 120 points -- that's all I have left...
Thanks for any help