Data Structures & AlgorithmsVery hardGATE CS · Codeforces Div2 B

How many index pairs i < j in [3, 4, 2, 6, 1, 2, 12, 1] have a[i] * a[j] = 12?

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

Correct answer: B. 5

The product 12 arises from 3 * 4 (once), 2 * 6 (twice, using the two 2s) and 1 * 12 (twice, using the two 1s), giving 5 position pairs.

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

Exams that ask this topic