You now understand queues and deques:
Queues: FIFO structure. needed for BFS and processing in arrival order.
Deques: Double-ended access. Add and remove from both ends in .
Monotonic deques: Find max/min over sliding windows in . Store indices, maintain sorted order, remove dominated elements.
DP optimization: When transitions look at max/min over last states, use monotonic deques to go from to . The monotonic deque is less famous than the monotonic stack, but equally powerful. learn both. In the next section, I'll show you hash tables for lookups.