Data Structures & AlgorithmsHardICPC regional · GATE CS top band

Array A = [9, 3, 3, 8, 2, 4, 3] (indices 0 to 6). Count the non-empty subsets of positions (each position used at most once, subsets not ordered) whose values add up to exactly 15.

  1. A. 143
  2. B. 8
  3. C. 128
  4. D. 60

Correct answer: B. 8

Enumerating all subsets of indices gives 8 with sum 15. Allowing each value to be reused, as in the coin-change count, gives 143.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic