Monotonic Queue
Monotonic Queue
Twenty questions on the monotonic queue (deque) pattern, for sliding-window minimum and maximum problems.
Continuous Subarrays
mediumYou are given a 0-indexed integer array nums.
Count Partitions With Max-Min Difference at Most K
mediumYou are given an integer array nums and an integer k.
Count Prime-Gap Balanced Subarrays
mediumYou are given an integer array nums and an integer k.
Jump Game VI
mediumYou are given a 0-indexed integer array nums and an integer k.
Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit
mediumGiven an array of integers nums and an integer limit, return the size of the longest non-empty subarray such that the absolute difference between any two elements of this subarray...
Maximum Sum Circular Subarray
mediumGiven a circular integer array nums of length n, return the maximum possible sum of a non-empty subarray of nums.
Minimum Number of Coins for Fruits
mediumYou are given an 0-indexed integer array prices where prices[i] denotes the number of coins needed to purchase the (i + 1)th fruit.
Constrained Subsequence Sum
hardGiven an integer array nums and an integer k, return the maximum sum of a non-empty subsequence of that array such that for every two consecutive integers in the subsequence,...
Count Non-Decreasing Subarrays After K Operations
hardYou are given an array nums of n integers and an integer k.
Count Subarrays With Fixed Bounds
hardYou are given an integer array nums and two integers minK and maxK.
Delivering Boxes from Storage to Ports
hardYou have the task of delivering some boxes from storage to their ports using only one ship.
Find Maximum Non-decreasing Array Length
hardYou are given a 0-indexed integer array nums.
Longest Increasing Subsequence II
hardYou are given an integer array nums and an integer k.
Max Value of Equation
hardYou are given an array points containing the coordinates of points on a 2D plane, sorted by the x-values, where points[i] = [xi, yi] such that xi < xj for all 1 <= i < j <=...
Maximum Number of Robots Within Budget
hardYou have n robots.
Maximum Number of Tasks You Can Assign
hardYou have n tasks and m workers.
Shortest Subarray with Sum at Least K
hardGiven an integer array nums and an integer k, return the length of the shortest non-empty subarray of nums with a sum of at least k.
Sliding Window Maximum
hardYou are given an array of integers nums, there is a sliding window of size k which is moving from the very left of the array to the very right.