Data Structures & AlgorithmsHardGATE CS · TCS NQT

How many distinct sums arise from the length-3 windows of [1, 1, 2, 2, 3, 3, 1]?

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

Correct answer: B. 4

The five windows have sums 4, 5, 7, 8, 7; the repeated 7 is counted once, giving 4 distinct values.

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

Exams that ask this topic