Data Structures & AlgorithmsHard

How many index pairs i < j in 2 3 4 6 8 12 9 satisfy A[i]·A[j] = 24?

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

Correct answer: C. 3

Each unordered index pair is tested once, so the product target 24 is matched by factor pairs present in the array. Using the wrong target, adding instead of multiplying, or doubling for order gives different totals.

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

Exams that ask this topic