Data Structures & AlgorithmsVery hardCodeforces Div2 B-D · ICPC regional

What is the length of the shortest contiguous subarray of [1, 2, 3, 1, 2, 4, 3] that contains every distinct value present in the array?

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

Correct answer: A. 4

The window [3, 1, 2, 4] is the shortest one that contains all four distinct values.

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

Exams that ask this topic