Data Structures & AlgorithmsHardGATE CS · TCS NQT

How many windows of size 3 in [2, 3, 5, 1, 4, 6, 4] have a sum that is a multiple of 5?

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

Correct answer: B. 2

Sliding window sums update in O(1) per step; checking each window sum modulo 5 gives the count. Windows like 2+3+5 = 10 qualify.

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

Exams that ask this topic