Bitmask
Use the bits of an integer as a set of booleans.
Decision · step 4 of 9Bitmask: A set in one integer
has 2: mask and (1 shl 2) is not zero, so element 2 is in.
What you will see
Each bit position is labelled with the element it represents; set membership is a lit bit.
Cost
| Space | O(1) |
|---|
How you work with it here
play it through, step one change at a time, run it on your own input, try operations in any order.
Screen readers: Each bit announces its position and value; each step announces the operation and the resulting number in binary and decimal.
Reduced motion: Bits flip with a crossfade; masks appear in place.