Data Structures & AlgorithmsHardProduct Company SDE · CP practice

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

  1. A. 8
  2. B. 10
  3. C. 5
  4. D. 9

Correct answer: D. 9

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

More Coding Interview Problems questions

Exams that ask this topic