Enter your book access code

The curriculum, drills, tutor, and interviewer mode are for readers of Ace the Rust Interview. The code is printed in the Preface (Companion site access).

Don’t have the book yet? The landing page stays open — purchase unlocks this gym.

intermediate · order 98

Sliding-window maximum

deque-max-01Related book chapters: 17 (optional — this page is complete on its own)monotonic-deque

Slug: deque-max-01 · Paired reading: Chapter 17

Prompt

fn max_sliding_window(nums: &[i32], k: usize) -> Vec<i32> — maximum of every contiguous window of length k. O(n) with a monotonic deque of indices.