Data Structures & AlgorithmsVery hardICPC regional · bitmask DP

Problem: Which technique computes the sum of a function over all subsets of a set of size n in O(n 2^n)?

  1. A. Floyd-Warshall
  2. B. Prim's algorithm
  3. C. Binary search
  4. D. Subset-sum-over-subsets (SOS) DP

Correct answer: D. Subset-sum-over-subsets (SOS) DP

SOS DP updates one bit at a time, giving O(n 2^n) for sums over submasks.

More Coding Interview Problems questions

Exams that ask this topic