Data Structures & AlgorithmsModerateTCS NQT Digital · Infosys

Problem: In the array [2, 7, 11, 15, 3, 8], how many pairs i < j have a[i] + a[j] equal to a multiple of 5?

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

Correct answer: C. 4

Brute force over index pairs with a residue test. Counting pairs whose sum equals exactly 5 or 10 misses larger multiples.

More Coding Interview Problems questions

Exams that ask this topic