Data Structures & AlgorithmsHardGATE CS · TCS NQT

How many windows of size 4 in [1, 2, 1, 3, 4, 2, 5, 6] contain four pairwise distinct values?

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

Correct answer: B. 4

A window is distinct when its set has size 4. Windows containing the repeated 1 or 2 fail, so only some of the five windows qualify.

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

Exams that ask this topic