AlgoScope

Bitmask

Use the bits of an integer as a set of booleans.

Bit manipulation, technique, intermediate
Element 2 is in the set.100201302403
Element 2 is in the set.100201302403

Bitmask: A set in one integer

Decision, step 4 of 9

has 2: mask and (1 shl 2) is not zero, so element 2 is in.

Cost

Space
O(1)

Leads to

Topics that need this one first.

Taught by the same lesson

Bitmask covers these too, in the same run.