Data Structures & AlgorithmsHardGATE CS · ICPC regional

A sliding window of size 3 moves over the array [5, 1, 4, 2, 8, 7, 6]. For each window take its maximum and then take the minimum of those maxima. What is the result?

  1. A. 5
  2. B. {C+7}
  3. C. 7
  4. D. 4

Correct answer: D. 4

The window maxima are 5, 4, 8, 8, 8; the minimum of these is 4. A monotonic deque produces the maxima in O(n).

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

Exams that ask this topic