Data Structures & AlgorithmsHard

How many contiguous windows of length exactly 3 in 6 10 15 4 9 7 14 3 have their three values PAIRWISE coprime (every two of them have gcd 1)?

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

Correct answer: C. 1

Pairwise coprimality needs all three pairs to have gcd 1, while the gcd of the whole window only tests the triple. Checking distinctness or only one adjacent pair answers a different question.

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

Exams that ask this topic