In python, you can find the intersection of two sets by just taking the bitwise AND of both sets like this: a & b, and it will return a new set with only the elements of both, but it uses the same algorithm.
a & b