Data Structures & AlgorithmsVery hard

In the sorted array [1, 1, 2, 2, 3, 4, 4, 5], how many different VALUE pairs {x, y} with x < y satisfy x + y = 6? (Repeated copies of a value do not create new value pairs.)

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

Correct answer: D. 2

Count distinct value pairs, so repeated copies collapse to one pair. Counting index pairs counts each copy separately, and allowing x = y (not asked) includes ordered duplicates.

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

Exams that ask this topic