Data Structures & AlgorithmsHard

How many index triples i < j < k in 1 2 2 3 4 6 8 satisfy A[i] · A[j] = A[k]?

  1. A. 6
  2. B. 8
  3. C. 24
  4. D. 11

Correct answer: A. 6

Enumerate index triples in order and test the product of the first two against the third value. Replacing the product by a sum, using ≤, or counting pairs whose product appears anywhere answers a different question.

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

Exams that ask this topic