Data Structures & AlgorithmsHardProduct Company SDE · CP practice

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

  1. A. 13
  2. B. 14
  3. C. 12
  4. D. 16

Correct answer: A. 13

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

More Coding Interview Problems questions

Exams that ask this topic