Deque Design Patterns — Sliding Window, Palindrome, Work Stealing
Master deque design patterns including sliding window maximum, palindrome checking, work stealing, and BFS/DFS hybrid. Python implementations.
29 posts · page 1 of 1
Master deque design patterns including sliding window maximum, palindrome checking, work stealing, and BFS/DFS hybrid. Python implementations.
Master BFS using queues for tree level-order traversal and shortest path in unweighted graphs. Python implementations with detailed traces.
Design a Circular Deque with front/rear pointers on a fixed-size array. Python solution with all O(1) operations, visual trace, and edge case handling.
Design Front Middle Back Queue using two balanced deques. Python solution with O(1) operations, step-by-step trace, and complexity analysis for LeetCode 1670.
Design a hit counter that counts hits in the past 5 minutes using a queue. LeetCode 362 solution with O(1) amortized operations.
Find the first non-repeating character in a character stream using a queue and hash map. Python solution with O(1) amortized per query.
Implement a stack using two queues with costly push and costly pop approaches. Complete Python solutions with complexity analysis.
Calculate the moving average from a data stream using a queue with fixed window size. LeetCode 346 solution with O(1) per operation.
Solve Number of Recent Calls using a queue as a 3000ms sliding window counter. Python solution with deque, step-by-step trace, and amortized analysis.
Solve Jump Game III (LeetCode 1306) and Jump Game IV (LeetCode 1345) using BFS. Covers graph modeling of array problems with queue-based traversal.
Open the Lock problem solved with BFS on 4-digit state space. Python solution with deadend handling, bidirectional BFS optimization, and complexity analysis.
Solve the Rotten Oranges problem (LeetCode 994) using multi-source BFS. Covers the simultaneous spread pattern, Python code, and grid BFS template.
Find the shortest path in a binary matrix using BFS with 8-directional movement. LeetCode 1091 solution with Python code and grid traversal tips.
Shortest Subarray with Sum at Least K solved with monotonic deque and prefix sums. Python solution with detailed trace, complexity analysis, and edge cases.
Solve the sliding window maximum problem in O(n) using a monotonic deque. Covers the algorithm, Python code, visual traces, and variations.
Solve Snakes and Ladders with BFS to find minimum dice rolls. Python solution with 1D-2D conversion, boustrophedon layout, and step-by-step trace.
Solve the Task Scheduler problem (LeetCode 621) using a queue and max-heap. Covers the greedy formula and simulation approaches with Python code.
Fill each empty room with the distance to its nearest gate using multi-source BFS. LeetCode 286 solution with Python code and grid BFS template.
Word Ladder solved with BFS and pattern matching optimization. Step-by-step Python solution for LeetCode 127 with complexity analysis and interview tips.
Zigzag level order traversal of a binary tree using BFS and deque. Step-by-step Python solution with visual trace, complexity analysis, and interview tips.
Implement a queue using two stacks with amortized O(1) operations. Covers costly enqueue vs costly dequeue approaches with Python code.
Comprehensive catalog of 15+ stack and queue interview patterns with when-to-use guide, Python templates, complexity analysis, and problem mapping for coding interviews.
Real-world applications of stacks and queues: undo/redo systems, browser history, call stacks, task scheduling, message queues, and BFS web crawlers with Python examples.
Build a circular queue from scratch — understand ring buffers, front/rear pointer math with modulo, full vs empty detection, and real-world uses in OS scheduling.
Master queue variants — simple queue, deque, circular queue, and priority queue. Implementations in Python with BFS, sliding window, and scheduling examples.
A practical guide to wiring Celery into Django for background work, scheduled jobs, and reliable task processing.
Build a reliable background job system in Node.js using Redis and BullMQ, with queues, workers, retries, and scheduled jobs.
A practical introduction to stacks and queues — LIFO vs FIFO, using a Python list as a stack, collections.deque as a queue, and the real-world problems each one solves cleanly.
Eight classic stack and queue interview problems with worked Python solutions — Valid Parentheses, Min Stack, Daily Temperatures, Sliding Window Maximum, and more.