An algorithm to find the difference of two set A and B with size n
问题 There are two set A and B, and the size of both sets is n. How to find every elements of A that is not in B (A-B), with O(n). What data structure should I use (bloom filter?) 回答1: Given that both are sets, you should use a set / hashset. This will let you compute the contains / in operation in O(1) . Bloom filters aren't good for this type of problem - they tell you if an element definitely isn't in a set of objects, but there are still chances for false positives. You're better off using a