Data Structures & AlgorithmsVery hardICPC regional · algorithm theory

Problem: Which statement about the subset-sum problem with target S and n items is correct in the standard sense?

  1. A. It is solvable in O(n) for any S
  2. B. It is NP-complete only when the items are negative
  3. C. A bitset or boolean DP solves it in O(n * S), which is pseudo-polynomial in the numeric value of S
  4. D. It is solvable in O(log S) by binary search

Correct answer: C. A bitset or boolean DP solves it in O(n * S), which is pseudo-polynomial in the numeric value of S

The DP over sums takes O(nS) time, which is polynomial in n and S but not in the input size log S.

More Coding Interview Problems questions

Exams that ask this topic