Deque

medium

O(1) push and pop at the front and the back. That combination is what makes the sliding-window maximum trick possible - every element enters and leaves exactly once.

Worst O(1) at both endsSpace O(n)
Loading the deque engine…

Where to go next