I have a two lists of objects and I would like to remove the instances from one list which is there in other list.
e.g. I have following two lists and suppose each letter represents the object.
List listA = {A, B, C , D, E, F, G, H , I , J}
List listB= {D, G, K, P, Z}
Now, clearly listB has D and G which are there on listA too so I want listA to be like this
listA = {A, B, C , E, F, H , I , J}
Can you guys please suggest what would be the solution for this with O(n) or less than O(n2).
I can iterate over both the lists and remove the duplicate instances by comparing but I want to have something more efficient.