Data Structures & AlgorithmsModerateTCS NQT Digital · Infosys

Problem: A list is [5, 9, 2, 7]. How many pairs (i, j) with i < j have a[i] + a[j] greater than 10?

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

Correct answer: A. 4

Test all six pairs: 5+9, 5+7, 9+2 and 9+7 exceed 10, while 5+2 and 2+7 do not. The answer is four pairs.

More Coding Interview Problems questions

Exams that ask this topic