3 ms·
I had a case today where I was comparing two sets for equality. If the range of values is large, you could xor everything together as a O(1) space check for lik
by physicles 6y ago
I had a case today where I was comparing two sets for equality. If the range of values is large, you could xor everything together as a O(1) space check for likely equality. Result is nonzero -> sets definitely aren’t equal; result is zero -> sets are probably equal, but you’ll need to check again some other way to make sure.
Of course this is absurd if you’re dealing with anything that already fits in ram, but it’s still neat to think about.