GATE Computer ScienceHardGATE CS (PYQ pattern)

The numbers 19, 5, 9, 18, 10, 29, 5, 24, 10 are split into two groups (every number goes into exactly one group). What is the smallest possible absolute difference between the two group sums?

  1. A. 1
  2. B. 5
  3. C. 3
  4. D. 7

Correct answer: C. 3

The total is 129 (odd), so the difference is odd. The subset-sum DP over reachable sums shows that 64 and 65 are not reachable, while 63 and 66 are, so the best split is 63 versus 66, giving |129 − 2·63| = 3 (verified by enumeration of all subset sums).

More Algorithms questions

Exams that ask this topic