Queue Practice Problems in C/C++
The following is the list of C/C++ programs based on the level of difficulty:
Easy
- Reversing a Queue
- Reversing the First K Elements of a Queue
- Implement Queue using Two Stacks
- Implement Stack using Queue
- Minimum Sum of Two Numbers Formed from Digits of an Array
- Maximum Number of Diamonds that can be gained in K Minutes
- First Negative Integer in Every Window of Size K
- First Negative Integer in Every Window of Size K
- Connect N Ropes with Minimum Cost
Medium
- Sorting a Queue without Extra Space
- Find the First Circular Tour that Visits All Petrol Pumps
- Design a Hit Counter
- Flood Fill Algorithm
- An Interesting Method to Generate Binary Numbers from 1 to N
- Minimum Sum of Squares of Character Counts in a Given String after Removing K Characters
- Interleave the First Half of the Queue with the Second Half
- Minimum Time Required to Rot All Oranges
- Sliding Window Maximum (Maximum of All Subarrays of Size K)
Hard
- Find the First Non-repeating Character from a Stream of Characters
- Sum of Minimum and Maximum Elements of all Subarrays of Size K
- An Interesting Method to Generate Binary Numbers from 1 to n
- Snake and Ladder Problem
- Find the First Circular Tour that Visits all Petrol Pumps
- Shortest Path in a Binary Maze
Stack and Queue C/C++ Programs
The stack and queue are popular linear data structures with a wide variety of applications. The stack follows LIFO (Last In First Out) principle where the data is inserted and extracted from the same side. On the other hand, the queue follows FIFO (First In First Out) principle, i.e., data is inserted at one side and extracted from the other side.
In this article, we will study some of the most common practice problems in C/C++ to improve our understanding of stack and queue data structures.
Prerequisite: Stack Data Structure, Queue Data Structure