Embercode
✕
Dynamic ProgrammingQuick quiz

Subset sums

8 questions. Covers Target sum by transforming to subset sum.

Questions 1 to 5 of 8

  1. 1. In the bitset version, what does reachable << x do to the set of reachable totals?
  2. 2. The numbers are 1, 1, 1, 1, 1 and the target is 3. Which value of P does the subset count use?
  3. 3. True or false: the bitset version of canPartition needs its size to be a compile-time constant.
  4. 4. True or false: if T + target is odd, the answer is 0, because every sign pattern has the same parity as T.
  5. 5. What does this program print? ``cpp #include <bitset> #include <iostream> int main() { std::bitset<12> reachable; reachable[0] = true; for (int x : {3, 4}) { reachable |= reachable << x; } std::cout << reachable.count() << "\n"; } ``

5 question(s) left on this page.