Pattern
Queue
A compact view of archive entries grouped by recurring technique.
27 entries
27 entries tagged as Queue.
06.12.2025
medium3578. Count Partitions With Max-Min Difference at Most K
Ways to partition into parts (max-min) at most k queue
03.10.2025
hard407. Trapping Rain Water II
Fill water in 3D
27.01.2025
medium1462. Course Schedule IV
All innodes for each query in graph warshall
18.01.2025
hard1368. Minimum Cost to Make at Least One Valid Path in a Grid
Min undirected jumps to reach the end in grid
17.11.2024
hard862. Shortest Subarray with Sum at Least K
Min subarray with sum at least k queue
28.09.2024
medium641. Design Circular Deque
Ring buffer
31.08.2024
medium1514. Path with Maximum Probability
Max path in graph
15.08.2024
easy860. Lemonade Change
Simulate money exchange
28.07.2024
hard2045. Second Minimum Time to Reach Destination
Second min time to travel from 1 to n in time-edged graph stopping every change seconds
23.06.2024
medium1438. Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit
Longest subarray with abs(a[i] - a[j]) <= limit window queue
08.05.2024
easy506. Relative Ranks
Convert results array to ranks array
22.04.2024
medium752. Open the Lock
Steps to rotate 4-wheel 0000 -> target
09.04.2024
easy2073. Time Needed to Buy Tickets
Seconds to buy tickets by k-th person in a rotating 1 second queue
08.04.2024
easy1700. Number of Students Unable to Eat Lunch
First sandwitch not eaten by any while popped from a queue
29.01.2024
easy232. Implement Queue using Stacks
Queue by 2 stacks.
15.11.2023
medium1846. Maximum Element After Decreasing and Rearranging
Max number from converting array to non decreasing
18.09.2023
easy1337. The K Weakest Rows in a Matrix
k indices with smallest row sum in a binary matrix
28.08.2023
easy225. Implement Stack using Queues
Create a Stack using Queue's push/pop methods.
22.07.2023
medium688. Knight Probability in Chessboard
Probability of making k steps on a chessboard without stepping outside
15.07.2023
hard1751. Maximum Number of Events That Can Be Attended II
Max sum of at most k values from non-intersecting array of (from, to, value) items
26.06.2023
medium2462. Total Cost to Hire K Workers
The sum of the smallest cost from suffix and prefix of a costs size of candidates in k iterations
4.05.2023
medium649. Dota2 Senate
Use Queue and count how many bans are from the Radiant and from the Dire.
23.02.2023
hard502. IPO
Sort items by increasing capital. Then, on each step, add all possible deals to the priority queue and take one best from it.
11.01.2023
medium1443. Minimum Time to Collect All Apples in a Tree
fun minTime(n: Int, edges: Array
16.12.2022
easy232. Implement Queue using Stacks
class MyQueue() {
21.11.2022
mediumNearest Exit From Entrance In Maze
fun nearestExit(maze: Array
6.11.2022
hardOrderly Queue
One idea that come to my mind is: if k >= 2 then you basically can swap any adjacent elements. That means you can actually sort all the characters.