Concept Flow - Sliding Window Maximum Using Deque
Start with empty deque
For each element in array
Remove indices from back if current element is greater
Add current index to back
Remove front if out of window
Record front element as max for current window
Move to next element
Repeat until end of array
We keep indexes of useful elements in a deque, removing smaller elements from the back and removing elements out of the window from the front, so the front always holds the max.