Data Structures & AlgorithmsHardCodeforces Div2 D · bitset DP

Problem: What is the time complexity of subset-sum over n items with a bitset of width W (up to 10^5)?

  1. A. O(2^n)
  2. B. O(W^2)
  3. C. O(n * W / 64)
  4. D. O(n^2 log W)

Correct answer: C. O(n * W / 64)

Each item shifts and ORs a W-bit bitset in W/64 word operations.

More Coding Interview Problems questions

Exams that ask this topic