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?
- A. 6
- B. 8
- C. 7
- 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
- A function returns the length of the longest strictly increasing subsequence (not necessarily contiguous). What does it return for [30…
- What is the length of the longest common subsequence of "DADEEDEE" and "CCDDDBC"?
- What is the length of the longest palindromic subsequence (not substring) of "BDDDACBBD"?
- A function returns the length of the longest strictly increasing subsequence (not necessarily contiguous). What does it return for [4, 7…
- What is the length of the longest common subsequence of "ABCDBEBC" and "CECCBBAAD"?
- A function returns the length of the longest strictly increasing subsequence (not necessarily contiguous). What does it return for [17, 4…