Data Structures & AlgorithmsHardGATE CS · Codeforces Div2 B

What is the sum of the maxima of every contiguous window of size 3 in the array [1, 3, -1, -3, 5, 3, 6, 7]?

  1. A. 29
  2. B. 26
  3. C. 32
  4. D. 58

Correct answer: A. 29

A monotonic deque keeps candidate maxima in decreasing order, so each window's maximum is at the front. Summing the window minima instead gives a different total.

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

Exams that ask this topic