I have two lists of objects, and I would like to remove instances from one list, which is in another list.
eg. I have the following two lists and assume that each letter represents an object.
ListA List = {A, B, C, D, E, F, G, H, I, J}
ListB = {D, G, K, P, Z}
Now, itβs clear that listB has D and G, which are in listA too, so I want listA to be like that
listA = {A, B, C, E, F, H, I, J}
Can you guys suggest what solution would be for this with O (n) or less than O (n2).
I can iterate over both lists and remove duplicate instances by comparison, but I want to have something more efficient.
source share