Data Structures & AlgorithmsHardCodeforces Div2 C · GATE CS

How many index pairs i < j of [1, 2, 4, 6, 7, 9] have a sum strictly between 5 and 10?

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

Correct answer: D. 5

Count pairs with sum at most 9 and subtract those with sum at most 5, or check each pair directly. The bounds 5 and 10 are both excluded.

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

Exams that ask this topic