Skip to main content

Sliding Window Maximum / Minimum

Learn Sliding Window Maximum / Minimum (Queue / Deque, Data Structures & Algorithms) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.

The Problem Given an array and a window size k, return the maximum (or minimum) of EVERY window as it slides across the array. This is the canonical monotonic-deque application: O(n) total instead of the naive O(n·k).

More lessons in Queue / Deque