Data Structures & AlgorithmsHardICPC regional · GATE CS top band

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

  1. A. 13
  2. B. 144
  3. C. 115
  4. D. 256

Correct answer: A. 13

Enumerating all subsets of indices gives 13 with sum 19. Allowing each value to be reused, as in the coin-change count, gives 144.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic