Concept Flow - Sliding Window Maximum Using Deque
Start with empty deque
For each element in array
Remove indices from front if out of window
Remove indices from back while current element > elements at those indices
Add current index to back
If window formed, record element at front as max
Repeat until end of array
We slide over the array, keeping indices of useful elements in a deque. We remove indices out of the window and smaller elements behind current to keep max at front.
