A set: hash table of keys — O(1) membership, no duplicates. A multiset: keys with counts.
Probe each element of A for membership in B. 1,2,3 miss; 4,5,6 hit → A ∩ B = {4,5,6}. Each probe O(1).
x in list is O(n); x in set is O(1)Record what you've seen → turn O(n²) scans into O(n). The most useful trick in the book.
Membership in O(1) → dedup, "seen before", counting. No order, no duplicates. Next tier: recursion & sorting.