Sliding Window Maximum [Hard] — Monotonic Deque
Find the maximum in every sliding window of size k in O(n) using a monotonic decreasing deque.
webcoderspeed.com
7 articles
Find the maximum in every sliding window of size k in O(n) using a monotonic decreasing deque.
Find the shortest subarray with sum >= K using a monotonic deque on prefix sums, handling negative numbers correctly.
Find the shortest subarray with sum >= k using a monotonic deque on prefix sums for O(n) time.
Find the maximum in every sliding window of size k in O(n) using a monotonic decreasing deque of indices.
Find the shortest subarray with sum >= k, handling negative numbers correctly using a monotonic deque on prefix sums.
Find the maximum in every sliding window of size k using a monotonic decreasing deque. O(n) solution that Google uses to test understanding of amortised data structures.
Simulate a snake game on a grid where the snake eats food to grow and dies if it hits walls or itself. Uses a deque for O(1) head/tail and a set for O(1) body collision checks.