Data Structures & AlgorithmsHardCodeforces Div2 C · GATE CS

How many distinct values arise as a sum of two different elements (by position) of [3, 5, 8, 10]?

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

Correct answer: D. 5

There are six position pairs with sums 8, 11, 13, 13, 15, 18; the repeated 13 is counted once in the set. Including equal positions adds the doubled values.

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

Exams that ask this topic