Data Structures & AlgorithmsHard

How many contiguous windows of length exactly 5 in 1 2 3 4 5 6 7 8 9 10 2 have a PRIME sum?

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

Correct answer: D. 0

A fixed window of length 5 has its sum updated by adding the entering value and removing the leaving one. Odd sums are only a necessary condition for primes, and changing the window length answers a different question.

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

Exams that ask this topic