Data Structures & AlgorithmsModerateTCS NQT · Accenture

What is the total number of distinct values obtained by summing two different elements of [1, 2, 3, 4] (order does not matter)?

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

Correct answer: A. 5

The six pair sums are 3, 4, 5, 5, 6, 7, and the duplicate 5 must be counted once. Counting pairs gives six, not the distinct count.

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

Exams that ask this topic