Stack Practice Problems in C/C++
The following is the list of C/C++ programs based on the level of difficulty:
Easy
- How to Reverse a String Using Stack
- Implement Two Stacks in an Array
- Check for Balanced Brackets in an Expression (Well-formedness)
- Remove all Duplicate Adjacent Characters from a String Using Stack
- Evaluation of Postfix Expression
- Check if Two Strings after Processing Backspace Character are Equal or Not
- Expression Contains Redundant Bracket or Not
- Find Maximum Depth of Nested Parenthesis in a String
- Find the Nearest Smaller Numbers on Left Side in an Array
- Sort a Stack Using a Temporary Stack
Medium
- How to Reverse a Stack Using Recursion
- Convert Infix Expression to Postfix Expression
- Next Greater Element (NGE) for Every Element in Given Array
- The Stock Span Problem
- Design a Stack with Operations on Middle Element
- Simplify the Directory Path (Unix Like)
- Minimum Number of Parentheses to be Added to Make it Valid
- Design and Implement Special Stack Data Structure | Added Space Optimized Version
- Next Greater Frequency Element
- Trapping Rain Water
Hard
- Length of the Longest Valid Substring
- Form Minimum Number from Given Sequence
- Largest Rectangular Area in a Histogram Using Stack
- Maximum Size Rectangle Binary Sub-matrix with All 1s
- Sum of Minimum Elements of All Subarrays
- Check if a Triplet of Buildings can be Selected such that the Third Building is Taller Than the First Building and Smaller than the Second Building
- Range Queries for Longest Correct Bracket Subsequence Set | 2
- Design a Stack which can Give Maximum Frequency Element
- Find Maximum of Minimum for Every Window Size in a Given Array
- Design Custom Browser History Based on Given Operations
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
Contact Us