Data Structures & AlgorithmsHardGATE CS · TCS NQT

How many subsets of [2, 5, 3, 7, 1] (chosen by position, empty subset included) have a total sum at most 8?

  1. A. 12
  2. B. 20
  3. C. 32
  4. D. 15

Correct answer: D. 15

Enumerate subsets or use a DP counting by sum with a prefix of capacities: the number of subsets with sum ≤ S is the sum of the DP entries up to S. Forgetting the empty subset, or using a strict inequality, gives a neighbouring count.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic