Data Structures & AlgorithmsHardGATE CS · ICPC regional

How many subsets of [2, 3, 5, 4, 6] (chosen by position) have a sum exactly equal to half of the total sum?

  1. A. 4
  2. B. 3
  3. C. 16
  4. D. 2

Correct answer: D. 2

Count subsets with target total/2 using a 0/1 subset-sum counting DP. The set and its complement come in pairs, so doubling the count is a common error when the question asks for distinct splits of the set into two halves.

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

Exams that ask this topic