Mental Model
Keep track of the biggest numbers in the current window using a special list that quickly removes smaller numbers.
Analogy: Imagine you are watching runners in a race and only remember the fastest ones ahead, forgetting slower runners behind you as you move forward.
Array: [2, 1, 3, 4, 6, 3, 8, 9, 10, 12, 56] Window size = 4 Deque stores indexes of elements in decreasing order of their values Example: Deque: [6, 7, 8, 9] (indexes of 8, 9, 10, 12) Window covers elements: 8, 9, 10, 12 Maximum is at front: 12
