Coding Test Practice - Candidate Key
- Iterating over every combination
Getting all 2^N combinations of consecutive numbers with bitmasking
for (int i=0; i < (1 << n); i++) cout << i;
- Property of the iteration
If we assume it's set A's turn,
every subset of A has already been processed.
- Checking if bits are a subset
For bits a, b,
if a & b == a,
then a is a subset of b.
- Watch out with string keys
When there are several strings,
you sometimes concatenate all the strings into one string, store it in a map,
and use it as a key.
In that case you need to put a separator like a space in between.
Otherwise you can get a counterexample where "a", "a", "bc" and "aa", "b", "c" end up with the same key "aabc".