Sliding window maximum
Keep a deque of the indices that could still be a window's maximum, their values decreasing from front to back. A new number removes every smaller value at the back — they leave the window first and can never win again — an index that slid out leaves from the front, and the front is always the maximum.
On nums the highlighted window has i at its right end. In maxWindow values decrease from first (the max, left) to last (right), with the index under each. ans holds the maximum of each window.