← All problems
Sliding Window Maximum
Given an integer array and a window size k, return the maximum value in each sliding window of size k as it moves from left to right. Achieve O(n) time.
Complexity
Time O(n), Space O(k)
Common pitfalls
- Heap without lazy deletion of stale entries
- Storing values instead of indices
Your solution
Log in to save your code and track progress.