Data Structures & AlgorithmsHardProduct Company SDE · CP practice

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

  1. A. 6
  2. B. 8
  3. C. 7
  4. D. 9

Correct answer: A. 6

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

More Coding Interview Problems questions

Exams that ask this topic