← 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?
- A.To keep the deque sorted from small to large
- B.They are older and smaller, so they can never be the maximum while the new value is in the window
- C.Because smaller values have already left the window
- 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 →