Data Structures19 sections · 729 units
Open in Course

Problem - Sliding Window Maximum

Classic deque problem

Given an integer array numsnums and an integer kk, return the maximum element in each sliding window of size kk. You're solving the textbook monotonic deque problem.

The solution is O(n)O(n) because each element is added to and removed from the deque at most once. Read the problem. Constraints are up to 10510^5 elements.