Data Structures & AlgorithmsHard

How many NON-EMPTY subsets of {1, 2, ..., 10} have a sum divisible by 10?

  1. A. 104
  2. B. 207
  3. C. 10
  4. D. 103

Correct answer: D. 103

A subset-sum count with a residue condition is a DP over residues mod 10; the empty subset is excluded. Testing divisibility by 5 instead, or counting only the subsets summing to exactly 10, each answer a different question.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic