Stack Data Structure
Learn more about Stack in DSA Self Paced Course
Practice Problems on Stack
Recent articles on Stack
What is Stack?
Stack is a linear data structure that follows a particular order in which the operations are performed. The order may be LIFO(Last In First Out) or FILO(First In Last Out).

Stack Data Structure
There are many real-life examples of a stack. Consider an example of plates stacked over one another in the canteen. The plate which is at the top is the first one to be removed, i.e. the plate which has been placed at the bottommost position remains in the stack for the longest period of time. So, it can be simply seen to follow LIFO(Last In First Out)/FILO(First In Last Out) order.
Topics :
- Introduction to Stack – Data Structure and Algorithm Tutorials
- Applications, Advantages and Disadvantages of Stack
- Implement a stack using singly linked list
- Introduction to Monotonic Stack
Implementation of Stack in different languages:
- Stack in C++ STL
- Stack Class in Java
- Stack in Python
- Stack in C#
- Implementation of Stack in JavaScript
- Stack in Scala
Some other Implementation of Stack:
- Implement Queue using Stacks
- Design and Implement Special Stack Data Structure | Added Space Optimized Version
- Implement two stacks in an array
- Implement Stack using Queues
- How to efficiently implement k stacks in a single array?
- Design a stack that supports getMin() in O(1) time and O(1) extra space
- Implement a stack using single queue
- How to implement stack using priority queue or heap?
- Create a customized data structure which evaluates functions in O(1)
- Implement Stack and Queue using Deque
- Easy:
- Infix to Postfix Conversion using Stack
- Prefix to Infix Conversion
- Prefix to Postfix Conversion
- Postfix to Prefix Conversion
- Postfix to Infix
- Convert Infix To Prefix Notation
- Check for balanced parentheses in an expression
- Arithmetic Expression Evalution
- Evaluation of Postfix Expression
- Reverse a stack using recursion
- Reverse individual words
- Reverse a string using stack
- Reversing a Queue
- Medium:
- How to create mergable stack?
- The Stock Span Problem
- Next Greater Element
- Next Greater Frequency Element
- Maximum product of indexes of next greater on left and right
- Iterative Tower of Hanoi
- Sort a stack using a temporary stack
- Reverse a stack without using extra space in O(n)
- Delete middle element of a stack
- Check if a queue can be sorted into another queue using a stack
- Check if an array is stack sortable
- Iterative Postorder Traversal | Set 1 (Using Two Stacks)
- Largest Rectangular Area in a Histogram | Set 2
- Find maximum of minimum for every window size in a given array
- Find index of closing bracket for a given opening bracket in an expression
- Find maximum difference between nearest left and right smaller elements
- Delete consecutive same words in a sequence
- Check mirror in n-ary tree
- Reverse a number using stack
- Reversing the first K elements of a Queue
- Hard:
- The Celebrity Problem
- Print next greater number of Q queries
- Iterative Postorder Traversal | Set 2 (Using One Stack)
- Print ancestors of a given binary tree node without recursion
- Length of the longest valid substring
- Expression contains redundant bracket or not
- Find index of closing bracket for a given opening bracket in an expression
- Find if an expression has duplicate parenthesis or not
- Find next Smaller of next Greater in an array
- Iterative method to find ancestors of a given binary tree
- Stack Permutations (Check if an array is stack permutation of other)
- Spaghetti Stack
- Remove brackets from an algebraic string containing + and – operators
- Range Queries for Longest Correct Bracket Subsequence
Recomended:
GeeksforGeeks Courses:
Complete Interview Preparation
Get fulfilled all your interview preparation needs at a single place with the Complete Interview Preparation Course that provides you with all the required stuff to prepare for any product-based, service-based, or start-up company at the most affordable prices. Get access to over 200 coding questions, premium lectures, theoretical resources, practice tracks, and much more.
Live Courses
In GFG Live Classes, Get best-in-industry Interactive LIVE & Self-Paced Courses with Individual Attention by Leading Industry Experts to level up yourself and get into your dream company. Get real-time GFG Live Courses from the industry experts to encourage out-of-the-box thinking, leading to clarity in concepts, creativity and innovative ideas. Check out GeeksforGeeks valuable Live Courses –System Design Live, Competitive Programming Live, and more!
Language Foundation Courses[C Programming / C++ / JAVA / Python ]
Explore GeeksforGeeks Language Foundation Courses – C Programming | Java Foundation | Python Foundation | C++ Foundation – Learn any programming language from scratch and understand all of its core fundamentals for a strong programming foundation in the simplest way and best price possible with GeeksforGeeks Language Foundation Courses. These courses are for complete beginners who want to get started with programming and build their foundation.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.