Data Structures & AlgorithmsHardProduct Company SDE · CP practice

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

  1. A. 24
  2. B. 11
  3. C. 13
  4. D. 12

Correct answer: D. 12

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

More Coding Interview Problems questions

Exams that ask this topic