Skip to content

Commit 4e373fc

Browse files
authored
Update README.md
1 parent 5f6b4a6 commit 4e373fc

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,60 @@
1+
<h1 align='center'>STACK - DATA STRUCTURE - PROBLEMS</h1>
12

3+
<p align='center'>A <b>Stack</b> is a linear data structure that follows the **Last In, First Out (LIFO)** principle. In simple terms, the last element added to the stack is the first one to be removed. A stack is often compared to a stack of plates, where the last plate placed on top is the first one to be taken off.
4+
</p>
5+
6+
### Repository Content
7+
8+
<p>
9+
<img src="https://img.shields.io/badge/problems%20count-06-orange?logo=leetcode" alt="LeetCode">
10+
<img src="https://img.shields.io/badge/problems%20count-09-darkgreen?logo=geeksforGeeks" alt="GeeksforGeeks">
11+
<img src="https://img.shields.io/badge/total%20problems%20count-20-blue" alt="Problem Count">
12+
</p>
13+
14+
| No | Problem Name | Description | LeetCode | GFG |
15+
| --- | ------------ | ----------- | -------- | --- |
16+
| 01 | [Example](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/15%20-%20Stack%20Data%20Structure%20Problems/01%20-%20Example) | Example problem | Non | Non |
17+
| 02 | [Stack Implementation Using Arrays - NO STL](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/15%20-%20Stack%20Data%20Structure%20Problems/02%20-%20Stack%20Implementation%20Using%20Arrays%20-%20NO%20STL) | Stack implementation without STL | Non | Non |
18+
| 03 | [Stack Implementation Using Linked List - NO STL](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/15%20-%20Stack%20Data%20Structure%20Problems/03%20-%20Stack%20Implementation%20Using%20Linked%20List%20-%20NO%20STL) | Stack implementation using Linked List without STL | Non | Non |
19+
| 04 | [Implement two Stacks in an Array](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/15%20-%20Stack%20Data%20Structure%20Problems/04%20-%20Implement%20two%20Stacks%20in%20an%20Array) | Implement two stacks in a single array | Non | [Link](https://www.geeksforgeeks.org/problems/implement-two-stacks-in-an-array/1) |
20+
| 05 | [Reverse a String Using Stack](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/15%20-%20Stack%20Data%20Structure%20Problems/05%20-%20Reverse%20a%20String%20Using%20Stack) | Reverse a string using stack | Non | Non |
21+
| 06 | [Delete Middle Element of a Stack](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/15%20-%20Stack%20Data%20Structure%20Problems/06%20-%20Delete%20Middle%20Element%20of%20a%20Stack) | Delete the middle element of a stack | Non | [Link](https://www.geeksforgeeks.org/problems/delete-middle-element-of-a-stack/1) |
22+
| 07 | [Valid Parentheses](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/15%20-%20Stack%20Data%20Structure%20Problems/07%20-%20Valid%20Parentheses) | Check if parentheses are valid | [Link](https://leetcode.com/problems/valid-parentheses/) | Non |
23+
| 08 | [Insert an Element at The Bottom of a Stack](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/15%20-%20Stack%20Data%20Structure%20Problems/08%20-%20Insert%20an%20Element%20at%20The%20Bottom%20of%20a%20Stack) | Insert an element at the bottom of a stack | Non | [Link](https://www.geeksforgeeks.org/problems/insert-an-element-at-the-bottom-of-a-stack/0) |
24+
| 09 | [Reverse a Stack](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/15%20-%20Stack%20Data%20Structure%20Problems/09%20-%20Reverse%20a%20Stack) | Reverse a stack | Non | [Link](https://www.geeksforgeeks.org/problems/reverse-a-stack/1) |
25+
| 10 | [Sort a Stack](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/15%20-%20Stack%20Data%20Structure%20Problems/10%20-%20Sort%20a%20Stack) | Sort a stack | Non | [Link](https://www.geeksforgeeks.org/problems/sort-a-stack/1) |
26+
| 11 | [Expression Contains Redundant Bracket or Not](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/15%20-%20Stack%20Data%20Structure%20Problems/11%20-%20Expression%20Contains%20Redundant%20Bracket%20or%20Not) | Check for redundant brackets in an expression | Non | [Link](https://www.geeksforgeeks.org/problems/expression-contains-redundant-bracket-or-not/0) |
27+
| 12 | [Minimum Add to Make Parentheses Valid](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/15%20-%20Stack%20Data%20Structure%20Problems/12%20-%20Minimum%20Add%20to%20Make%20Parentheses%20Valid) | Minimum number of operations to make parentheses valid | [Link](https://leetcode.com/problems/minimum-add-to-make-parentheses-valid/) | Non |
28+
| 13 | [Help Classmates](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/15%20-%20Stack%20Data%20Structure%20Problems/13%20-%20Help%20Classmates) | Help classmates problem | Non | [Link](https://www.geeksforgeeks.org/problems/help-classmates--141631/1?itm_source=geeksforgeeks&itm_medium=article&itm_campaign=practice_card) |
29+
| 14 | [Final Prices With a Special Discount In a Shop](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/15%20-%20Stack%20Data%20Structure%20Problems/14%20-%20Final%20Prices%20With%20a%20Special%20Discount%20In%20a%20Shop) | Final prices with a special discount | [Link](https://leetcode.com/problems/final-prices-with-a-special-discount-in-a-shop/) | Non |
30+
| 15 | [Largest Rectangle in Histogram](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/15%20-%20Stack%20Data%20Structure%20Problems/15%20-%20Largest%20Rectangle%20in%20Histogram) | Largest rectangle in histogram | [Link](https://leetcode.com/problems/largest-rectangle-in-histogram/) | Non |
31+
| 16 | [The Celebrity Problem](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/15%20-%20Stack%20Data%20Structure%20Problems/16%20-%20The%20Celebrity%20Problem) | The celebrity problem | Non | [Link](https://www.geeksforgeeks.org/problems/the-celebrity-problem/1) |
32+
| 17 | [Maximal Rectangle](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/15%20-%20Stack%20Data%20Structure%20Problems/17%20-%20Maximal%20Rectangle) | Maximal rectangle problem | [Link](https://leetcode.com/problems/maximal-rectangle/) | Non |
33+
| 18 | [Implement N Stacks in a Single Array](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/15%20-%20Stack%20Data%20Structure%20Problems/18%20-%20Implement%20N%20Stacks%20in%20a%20Single%20Array) | Implement N stacks in a single array | Non | Non |
34+
| 19 | [Get Minimum Element from Stack](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/15%20-%20Stack%20Data%20Structure%20Problems/19%20-%20Get%20Minimum%20Element%20from%20Stack) | Get minimum element from stack | Non | [Link](https://www.geeksforgeeks.org/problems/get-minimum-element-from-stack/1?itm_source=geeksforgeeks&itm_medium=article&itm_campaign=practice_card) |
35+
| 20 | [Min Stack](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/15%20-%20Stack%20Data%20Structure%20Problems/20%20-%20Min%20Stack) | Min stack implementation | [Link](https://leetcode.com/problems/min-stack/) | Non |
36+
37+
### Key Operations of a Stack
38+
39+
1. **Push**: Adds an element to the top of the stack.
40+
2. **Pop**: Removes the element from the top of the stack.
41+
3. **Peek/Top**: Returns the element at the top of the stack without removing it.
42+
4. **isEmpty**: Checks whether the stack is empty or not.
43+
5. **Size**: Returns the number of elements currently in the stack.
44+
45+
### Real-World Applications of Stacks
46+
47+
- **Function Calls**: The call stack in programming languages is implemented using stacks. When a function is called, its state (parameters, local variables, etc.) is pushed onto the stack. When the function returns, its state is popped off the stack.
48+
- **Undo Operations**: Many software applications, such as word processors, use stacks to keep track of changes so that the user can "undo" actions.
49+
- **Expression Evaluation**: Stacks are used for parsing expressions and evaluating postfix or infix expressions.
50+
- **Backtracking Algorithms**: Stack is used in algorithms like depth-first search (DFS) and solving puzzles (e.g., mazes, Sudoku).
51+
52+
### Implementation of Stacks
53+
54+
Stacks can be implemented using two primary data structures:
55+
56+
1. **Array**: A stack can be implemented using an array, where elements are pushed and popped from the end of the array.
57+
2. **Linked List**: A stack can also be implemented using a linked list, where elements are added and removed from the head of the list.
58+
59+
---
60+
Happy Coding 🙂

0 commit comments

Comments
 (0)