Top 50 Must-Do LeetCode Questions on Queues for Your Coding Interview Preparation
Queues are an essential data structure used in many real-world applications like scheduling, breadth-first search (BFS), and more. Below is a curated list of 50 queue-related LeetCode problems divided into Easy, Medium, and Hard categories, along with a brief two-liner description of each.
Easy Questions (20 Questions)
Implement Queue using Stacks (232)
Implement a queue using two stacks to handle enqueue and dequeue operations.Design Circular Queue (622)
Design a circular queue supporting efficient operations with a fixed capacity.Moving Average from Data Stream (346)
Maintain a moving average of integers from a data stream using a fixed-size queue.Number of Recent Calls (933)
Count the number of calls received within a given time frame using a sliding window.First Unique Character in a String (387)
Find the first non-repeating character in a string using a queue.Perfect Squares (279)
Find the least number of perfect square numbers that sum up to a given number using BFS.Open the Lock (752)
Find the minimum steps to unlock a combination lock using BFS.Rotting Oranges (994)
Determine the minimum time to rot all oranges in a grid using multi-source BFS.Binary Tree Level Order Traversal (102)
Perform a level-order traversal of a binary tree using a queue.Symmetric Tree (101)
Check if a binary tree is symmetric using BFS with a queue.Shortest Path in Binary Matrix (1091)
Find the shortest path from the top-left to the bottom-right in a binary grid.Walls and Gates (286)
Fill each empty room with the distance to its nearest gate using multi-source BFS.Island Perimeter (463)
Calculate the perimeter of an island represented in a grid.Breadth-First Search Traversal
Implement BFS traversal for a graph using a queue.Time Needed to Inform All Employees (1376)
Find the time required to inform all employees in a hierarchy using BFS.Course Schedule (207)
Check if all courses can be finished given prerequisites using topological sorting.Flood Fill (733)
Perform a flood-fill operation on a grid using BFS.Snakes and Ladders (909)
Find the minimum moves to reach the last square in a snakes and ladders game.Binary Tree Zigzag Level Order Traversal (103)
Traverse a binary tree in a zigzag level order using a queue.Sliding Window Maximum (239)
Find the maximum value in each sliding window of sizek.
Medium Questions (25 Questions)
Design Front Middle Back Queue (1670)
Implement a double-ended queue with front, middle, and back operations.Top K Frequent Elements (347)
Find the topkmost frequent elements in an array using a priority queue.Find the Winner of the Circular Game (1823)
Simulate a circular game using a queue to determine the winner.Jump Game VI (1696)
Find the maximum score you can achieve in a jump game with a sliding window queue.Course Schedule II (210)
Find the order of courses to finish all given prerequisites using BFS.K Closest Points to Origin (973)
Find thekclosest points to the origin using a priority queue.Task Scheduler (621)
Schedule tasks with cooling intervals using a queue.Reorganize String (767)
Rearrange a string so that no two adjacent characters are the same using a priority queue.Sum of Subarray Minimums (907)
Calculate the sum of minimum values of all subarrays using monotonic queues.Cheapest Flights Within K Stops (787)
Find the cheapest flight route with at mostkstops using a queue for BFS.Reach a Number (754)
Find the minimum steps to reach a target number starting from zero.Count Complete Tree Nodes (222)
Count the number of nodes in a complete binary tree using BFS.Shortest Bridge (934)
Find the shortest bridge between two islands using BFS.Remove All Adjacent Duplicates in String II (1209)
Remove adjacent duplicates in a string with a stack-queue hybrid approach.Kth Largest Element in a Stream (703)
Find the kth largest element from a dynamic data stream.Escape the Spreading Fire (2428)
Determine the earliest escape time given fire spreading on a grid.Data Stream as Disjoint Intervals (352)
Add intervals from a stream and return a disjoint set of intervals.Sliding Puzzle (773)
Solve a sliding puzzle using BFS to reach the goal state.Maximum Performance of a Team (1383)
Select a team to maximize performance using a priority queue.Sequential Digits (1291)
Generate numbers with sequential digits in a given range using BFS.The Maze (490)
Determine if the ball can stop at the destination in a maze using BFS.Find Eventual Safe States (802)
Find nodes in a graph that are eventually safe using BFS.Kill Process (582)
Kill a process and its children given a parent-child relationship.Employee Importance (690)
Calculate the total importance of an employee and their subordinates.Design Hit Counter (362)
Count the number of hits in a given time frame using a sliding window queue.
Hard Questions (5 Questions)
Minimum Cost to Connect Sticks (1167)
Connect sticks of varying lengths with the minimum cost using a priority queue.Merge k Sorted Lists (23)
Mergeksorted linked lists into one sorted list using a priority queue.LFU Cache (460)
Design an LFU (Least Frequently Used) cache with efficient operations.Minimum Number of Refueling Stops (871)
Determine the minimum number of refueling stops to reach a target.Swim in Rising Water (778)
Find the minimum time to swim from the top-left to the bottom-right in a grid.
By practicing these queue-related problems, you’ll develop a solid understanding of queue operations and their real-world applications. Which one are you solving first?
Top comments (0)