An integer mask is a compact set of yes-or-no flags. XOR marks differences and cancels equal values, making it useful for detecting changed permissions and recovering IDs with known occurrence counts. The occurrence rule matters. Two equal values cancel under XOR; three don't, so the later practice problem counts bit positions modulo three instead.
Decide the width explicitly. Reversing a 16-bit badge must include all its leading zeros. JavaScript number bitwise operations use signed 32-bit conversion, so these mask problems stay below 2^30. Ordinary arithmetic can represent larger integers, but silently mixing those assumptions loses high bits.
The final problem combines any subset of masks. It needs a binary basis rather than a search for the best pair. Explain why each stored basis vector introduces one independent highest bit, then maximize the result from high bits downward.