Data Structures & AlgorithmsHardCodeforces Div2 B · TCS NQT

The array [1, 9, 4, 6, 2, 8] has even length. You pair up the elements (each element in exactly one pair), and the cost of the arrangement is the largest pair sum. What is the minimum possible largest pair sum?

  1. A. 17
  2. B. 3
  3. C. 30
  4. D. 10

Correct answer: D. 10

Sort to 1, 2, 4, 6, 8, 9 and pair smallest with largest: 1+9, 2+8, 4+6 all equal 10, matching the lower bound 30/3 = 10. Pairing sorted neighbours gives 8 + 9 = 17, 3 is the minimum pair sum, and 30 is the total.

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

Exams that ask this topic