Data Structures & AlgorithmsModerateTCS NQT Digital · CAT

Problem: A bitmask represents a subset of the 4 items {A, B, C, D} by bits 0–3. How many subsets have an even number of items and do NOT contain item A (bit 0)?

  1. A. 5
  2. B. 3
  3. C. 6
  4. D. 4

Correct answer: D. 4

Enumerate the 16 masks, keep those with an even popcount and bit 0 clear. The empty set is included because it has zero items, which is even.

More Coding Interview Problems questions

Exams that ask this topic