Data Structures & AlgorithmsHardCodeforces Div2 C · GATE CS

How many windows of length 3 in [1, 2, 1, 2, 3, 3, 1] contain exactly two distinct values?

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

Correct answer: D. 4

A fixed window of size 3 with exactly two distinct values has one repeated value among its three entries. Windows with three distinct values or one repeated constant value are not counted.

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

Exams that ask this topic