Stage 1 · Code
Stacks & Queues
Deque
Double-ended queue for sliding window max/min problems.
Deque Concept
A deque (double-ended queue) allows O(1) insertion/removal at both front and rear. Go's container/list provides doubly-linked list which works as deque. Can also implement with circular array.
Monotonic Deque
A monotonic deque maintains elements in sorted order (increasing or decreasing). When adding new element, remove from back all elements that violate monotonicity. Front always holds min/max.
Sliding Window Maximum
Given array and window size k, find max in each window. Brute force O(nk). Monotonic deque achieves O(n). Each element pushed/popped at most once.
Mark this lesson complete to store local progress and unlock a cleaner resume path the next time you visit.