Data Structures & AlgorithmsHardProduct Company SDE · CP practice

How many subsets (by index, so equal values at different positions count separately) of [1, 3, 3, 5, 1, 5, 9, 5, 1] sum to exactly 11?

  1. A. 42
  2. B. 20
  3. C. 21
  4. D. 17

Correct answer: C. 21

Counting knapsack: dp[c] += dp[c−x] for each element with c descending → 21.

More Coding Interview Problems questions

Exams that ask this topic