Monotonic Queue for Max/Min — Sliding Window
The Monotonic Queue for Max/Min pattern applies when you need the Monotonic Queue for Max/Min technique within the Sliding Window pattern. Its time complexity is O(n) and space complexity O(k). It is used in 3 problems on Thita, including Jump Game VI, Shortest Subarray with Sum at Least K and Sliding Window Maximum. Common variations are Character Frequency Matching and Fixed Size (Subarray Calculation).
Master monotonic queue (deque) to find maximum or minimum in sliding windows efficiently in O(n) time.
Monotonic Queue for Max/Min is one of the 4 subpatterns of the Sliding Window pattern, which covers fixed-size, variable-size, and character frequency matching window techniques. The whole pattern is about 2.5 hours of study. This subpattern is a depth topic for once the core techniques are automatic.
What Monotonic Queue for Max/Min covers
Master the sliding window technique for subarray and substring problems. Learn fixed size windows, variable size windows, and monotonic queue optimizations. Problems in this subpattern are usually searched for as monotonic queue, sliding window maximum, deque, window max min, leetcode 239.
How to practise Monotonic Queue for Max/Min on Thita.ai
Read the theory for Monotonic Queue for Max/Min, then work the problems attached to it in the browser editor. Your solution runs against the problem's test cases, and the AI coach offers a hint about the technique you are missing rather than a finished solution. Progress is tracked per subpattern, so the Sliding Window tracker shows this one as covered once you have solved its problems.
Other subpatterns in Sliding Window
- Fixed Size (Subarray Calculation) — Learn fixed-size sliding window for subarray calculations like maximum average, moving average, and k-size subarray problems.
- Variable Size (Condition-Based) — Master variable-size sliding window for condition-based problems like longest substring without repeating characters.
- Character Frequency Matching — Learn sliding window with character frequency matching for anagram and permutation substring problems.
Related DSA patterns
- Two Pointers — Fast-slow, converging, expanding from center, and in-place modification techniques.
- Binary Search Patterns — Standard binary search, rotated arrays, first/last occurrence, and search on answer space.
- Array/Matrix Manipulation Patterns — In-place operations, hashing, prefix sums, spiral traversal, and cyclic sort.
- Linked List Manipulation Patterns — In-place reversal, merging sorted lists, reordering, and intersection detection.
Where to go next
Monotonic Queue for Max/Min is one lesson in a 16-pattern DSA course. If you are preparing end to end, work the interview-critical patterns first and use the pattern sheet as the checklist; if you are here for one technique, the Sliding Window guide is the shortest path back to the rest of it.