Data Structures & AlgorithmsHardProduct Company SDE · ICPC regional

Problem: A bitmask DP problem: count the subsets of {1, 2, ..., 10} whose sum is a multiple of 5 (the empty set counts, since its sum 0 is a multiple of 5).

  1. A. 207
  2. B. 208
  3. C. 204
  4. D. 104

Correct answer: B. 208

A DP over remainders mod 5 (each x adds dp[(r − x) mod 5]) gives 208 subsets including the empty set. Excluding the empty set gives 207, the estimate ⌊1024 / 5⌋ gives 204, and stopping at 9 elements gives 104.

More Coding Interview Problems questions

Exams that ask this topic