🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Queues and Deques: all 13 questions

Quiz: Queues and Deques · Question 13 of 13

In sliding window maximum, why remove smaller values from the back of the deque when a new value arrives?

In sliding window maximum, why remove smaller values from the back of the deque when a new value arrives?

  1. A.To keep the deque sorted from small to large
  2. B.They are older and smaller, so they can never be the maximum while the new value is in the window
  3. C.Because smaller values have already left the window
  4. D.Because the deque can hold only k items
Answer & explanation

Correct answer: They are older and smaller, so they can never be the maximum while the new value is in the window

The new value will stay in the window at least as long as they do, so they are useless from now on.

Can you get the rest right without peeking?

Take the timed Quiz: Queues and Deques quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →