A stack is a linear Last-In-Last-Out (LIFO) data structure which means that the last element added to the stack will be the first one to be removed. Therefore, once a new element is added to the stack, all elements that were added after it has to be removed before the new element can be removed.
In this post, we have listed out commonly asked interview questions that use stack data structure:
- Stack implementation using an array – C, C++, Java, PythonBeginner
- Stack Implementation using a Linked ListBeginner
- Implement a stack using the queue data structureMedium
- Implement a queue using the stack data structureMedium
- Design a stack that returns the minimum element in constant timeHard
- Design a stack that returns a minimum element without using an auxiliary stackHard
- Implement two stacks in a single arrayEasy
- Recursive solution to sort a stackHard
- Reverse a stack using recursionHard
- Reverse a string using a stack data structureEasy
- Check if an expression is balanced or notEasy
- Find duplicate parenthesis in an expressionMedium
- Evaluate a postfix expressionEasy
- Decode a given sequence to construct a minimum number without repeated digitsHard
- Merging Overlapping IntervalsMedium
- Convert an infix expression into a postfix expressionMedium
- Find the next greater element for every element in a circular arrayHard
- Find the next greater element for every array elementMedium
- Find the previous smaller element for each array elementMedium
- Reverse an array in C++Easy
- Longest Increasing Subsequence ProblemHard
- Find all elements in an array that are greater than all elements to their rightEasy
- Iterative Implementation of QuicksortMedium
- Find all binary strings that can be formed from a wildcard patternMedium
- Find the length of the longest balanced parenthesis in a stringHard
- Reverse text without reversing individual wordsMedium
- Reverse a string without using recursionEasy
- Inorder Tree TraversalMedium
- Preorder Tree TraversalMedium
- Postorder Tree TraversalMedium
- Check if two binary trees are identical or notEasy
- Find ancestors of a given node in a binary treeMedium
- Iteratively print the leaf to root path for every leaf node in a binary treeMedium
- Find preorder traversal of a binary tree from its inorder and postorder sequenceHard
- Construction of an expression treeEasy
- Print complete Binary Search Tree (BST) in increasing orderEasy
- Depth First Search (DFS)Medium
- Check whether the leaf traversal of given binary trees is the same or notHard
- Reverse level order traversal of a binary treeEasy
- Invert Binary TreeEasy
- Invert alternate levels of a perfect binary treeHard
- Depth-First Search (DFS) vs Breadth-First Search (BFS)Beginner
Thanks for reading.
To share your code in the comments, please use our online compiler that supports C, C++, Java, Python, JavaScript, C#, PHP, and many more popular programming languages.
Like us? Refer us to your friends and support our growth. Happy coding :)