Data Structures & AlgorithmsHardTCS NQT · Product Company SDE

Problem: The subset-sum DP over the values [2, 3, 7, 8, 10] asks: how many subsets have sum exactly 11? The empty subset has sum 0 and is not counted.

  1. A. 2
  2. B. 0
  3. C. 3
  4. D. 1

Correct answer: D. 1

The standard 0/1 subset-count DP iterates sums downward so each element is used once. Iterating upward would let an element be counted repeatedly and change the answer.

More Coding Interview Problems questions

Exams that ask this topic