Data Structures & AlgorithmsHardTCS NQT Digital · CAT

Problem: In the array [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], find the number of pairs (i, j) with i < j whose product is a multiple of 12.

  1. A. 8
  2. B. 16
  3. C. 9
  4. D. 6

Correct answer: A. 8

Pairs with 12 | x·y among 1..10 (e.g. (2,6), (3,4), (3,8), (4,6), (6,8), (6,10), (4,9), (8,9)) number 8. Ordered pairs give 16, allowing x = y adds (6,6) for 9, and requiring one factor to hold all of 4 and the other all of 3 gives 6.

More Coding Interview Problems questions

Exams that ask this topic