← All problems

Sliding Window Maximum

Hard heapsdequesliding-window LeetCode ↗
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.

Hints (0/3 revealed)

Log in to reveal hints progressively.

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.