Monotonic Queue LeetCode Problems: All 17, With Python Solutions

Every problem in this library that LeetCode tags Monotonic Queue 17 in total, 15 of them with a complete Python solution, a worked example and the time and space complexity of the approach.

  • 17 problems
  • 0 Easy
  • 5 Medium
  • 12 Hard

How Monotonic Queue problems are solved

A tag names the subject, not the method. These pattern hubs cover the techniques that actually solve Monotonic Queue problems — each one explains the approach, gives a Python template and states its complexity.

  • Monotonic Stack — Answer "what is the next greater element" for every position in one pass.

Monotonic Queue problems by difficulty

Problems with a complete Python solution are listed first, then by ascending problem number.

Medium (5)

#ProblemDifficultyTopics
918Maximum Sum Circular SubarrayMediumQueue, Array, Divide and Conquer +2
1438Longest Continuous Subarray With Absolute Diff Less Than or Equal to LimitMediumQueue, Array, Ordered Set +3
1696Jump Game VIMediumQueue, Array, Dynamic Programming +2
2762Continuous SubarraysMediumQueue, Array, Ordered Set +3
2944Minimum Number of Coins for FruitsMediumQueue, Array, Dynamic Programming +2

Hard (12)

#ProblemDifficultyTopics
239Sliding Window MaximumHardQueue, Array, Sliding Window +2
862Shortest Subarray with Sum at Least KHardQueue, Array, Binary Search +4
1425Constrained Subsequence SumHardQueue, Array, Dynamic Programming +3
1499Max Value of EquationHardQueue, Array, Sliding Window +2
1687Delivering Boxes from Storage to PortsHardSegment Tree, Queue, Array +4
2071Maximum Number of Tasks You Can AssignHardGreedy, Queue, Array +4
2398Maximum Number of Robots Within BudgetHardQueue, Array, Binary Search +4
2407Longest Increasing Subsequence IIHardBinary Indexed Tree, Segment Tree, Queue +4
2444Count Subarrays With Fixed BoundsHardQueue, Array, Sliding Window +1
2945Find Maximum Non-decreasing Array LengthHardStack, Queue, Array +4
683K Empty SlotsPremiumHardBinary Indexed Tree, Segment Tree, Queue +5
2969Minimum Number of Coins for Fruits IIPremiumHardQueue, Array, Dynamic Programming +2

When the Monotonic Queue problem arrives live

Stealth Interview is a desktop app for macOS and Windows. It reads the coding problem off your screen, returns a working solution with a step-by-step explanation and its time and space complexity, and transcribes what the interviewer is saying — while staying invisible to screen sharing.