A set stored in one number
transcript
Fifteen analysts take fifteen review cases. Trying every order is impossible. Store the set as bits instead.
There are over a trillion orders. There are only 32,768 subsets. Store one value for each subset. The orders are never listed.
Mask five is one, zero, one. Items zero and two are used. Item one is free.
To test item j, shift right and keep one bit. To add item j, use or with one shifted left. Adding a bit makes the mask larger. So smaller masks are always done first.
Loop over masks from zero upwards. Every state is final when you read it. Downwards reads states not built yet.
Two histories can use the same set. Ask whether they can differ later. If not, the mask is the whole state. If so, add only the difference.
Store the used items as bits. Add only what the mask cannot tell. Full breakdown in the lecture.