Sliding Window Maximum
Find the maximum of every window of size k in one pass. Keep a deque of indices whose values only decrease, and each element is added and removed at most once.
Spotted a mistake in this lesson?Report an issue →
Find the maximum of every window of size k in one pass. Keep a deque of indices whose values only decrease, and each element is added and removed at most once.