Data Structures & AlgorithmsHardCodeforces Div2 C · GATE CS

How many index pairs i < j of [1, 2, 3, 4, 5] have a sum equal to the array's maximum?

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

Correct answer: D. 2

The maximum is 5, and the pairs summing to 5 are (1,4) and (2,3), giving 2. The check uses the fixed maximum, not the largest pair.

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

Exams that ask this topic