Data Structures & AlgorithmsVery hardICPC regional · Amazon SDE OA

How many distinct value pairs (x, y) with x < y satisfy x + y = 10 among the values of [1, 2, 3, 4, 5, 6, 7, 8, 9, 5]?

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

Correct answer: C. 4

Work with the set of values: each unordered value pair counted once. Counting index pairs (the last option) double-counts the value 5 when it appears twice.

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

Exams that ask this topic