Courses
Tutorials
Interview Prep
DSA
Practice Problems
C
C++
Java
Python
JavaScript
Data Science
Machine Learning
Courses
Linux
DevOps
Similar Topics
Web Technologies
32.1K+ articles
Misc
7.7K+ articles
Mathematical
5.1K+ articles
Arrays
4.2K+ articles
Strings
2.1K+ articles
Greedy
1.4K+ articles
Sorting
1.1K+ articles
Dynamic Programming
1.1K+ articles
Searching
1.0K+ articles
Tree
911+ articles
DSA
/
Data Structures
/
Stack
Stack
261+ posts
Recent Articles
Popular Articles
Why and when to use Stack or Queue instead of Arrays/Lists?
Last Updated: 23 July 2025
Stack:A stack is a linear data structure in which elements are accessed, inserted and deleted from one end called the top of the stack. Stack follows the LIFO ( Last In Fi...
read more
Stack
Picked
DSA
Why do we need Prefix and Postfix notations?
Last Updated: 01 July 2022
Prefix Notation:Prefix notation is the notation in which operators are placed before the corresponding operands in the expression.Example:Infix notation: A + B Prefix not...
read more
Stack
Picked
DSA
regular-expression
Implementation of stack using Doubly Linked List
Last Updated: 23 July 2025
Stack and doubly linked lists are two important data structures with their own benefits. Stack is a data structure that follows the LIFO (Last In First Out) order and can ...
read more
Linked List
Stack
Picked
DSA
doubly linked list
Find common elements of Stack and Queue
Last Updated: 23 July 2025
Given a stack of M elements and a queue of N elements in sorted order. The task is to find out the common elements of the stack and the queue.Examples:Input: stack = [1, 3...
read more
Stack
Queue
Searching
DSA
two-pointer-algorithm
Minimize deletions such that no even index Array element is same as next element
Last Updated: 23 July 2025
Given an array arr[], the task is to find the minimum number of deletion operations required such that:The newly created array should have an even length.arr[i] ≠ arr[i+1]...
read more
Stack
Greedy
DSA
Arrays
Maximum size rectangle binary sub-matrix with all 1s | Set 2
Last Updated: 23 July 2025
Given a binary matrix mat[][] of size n * m, your task is find the maximum area of the rectangle binary-sub-matrix with all 1’s.Examples:Input: mat[][] = [ [0, 1, 1, 0], ...
read more
Stack
Matrix
DSA
Amazon
Interchange elements of Stack and Queue without changing order
Last Updated: 23 July 2025
Given a stack St of M elements and a queue Q of N elements. The task is to put every element of stack into the queue and every element of the queue into the stack without ...
read more
Stack
Queue
Geeks Premier League
Geeks-Premier-League-2022
DSA
Replacing adjacent opposite sign pairs with their absolute max in an array
Last Updated: 22 April 2025
Given an array arr[] of size n, the task is to find the final array by repeatedly performing the following operations if two elements of opposite signs are adjacent:Remove...
read more
Stack
Geeks Premier League
Geeks-Premier-League-2022
DSA
Arrays
Check if two Binary trees are identical after exactly K changes
Last Updated: 23 July 2025
Given two binary trees T1 and T2 and integer K, the task is to check whether both trees are identical or not after making exactly K changes in the first tree. In each chan...
read more
Tree
Stack
Geeks Premier League
Geeks-Premier-League-2022
DSA
Inorder Traversal
Binary Tree
Count Subarrays with First Element as Minimum
Last Updated: 15 September 2025
Given an array arr[], Find the number of subarrays whose first element is not greater than other elements of the subarray.Examples:Input: arr[] = [1, 2, 1]Output: 5Explana...
read more
Stack
Geeks Premier League
Geeks-Premier-League-2022
DSA
Arrays
subarray
Maximum People Visible in a Line
Last Updated: 15 September 2025
Given an array arr[], where arr[i] represents the height of the i-th person standing in a line, a person i can see another person j if arr[j] is smaller than arr[i] and th...
read more
Stack
Greedy
Mathematical
DSA
Arrays
Reverse first K elements of the given Stack
Last Updated: 23 July 2025
Given a stack S and an integer K, the task is to reverse the first K elements of the given stackExamples:Input: S = [ 1, 2, 3, 4, 5, 8, 3, 0, 9 ], K = 4Output: [ 4, 3, 2, ...
read more
Stack
DSA
Reverse
Find lexicographical smallest string by performing the given operations N times
Last Updated: 23 July 2025
Given a string S of N characters, the task is to find the smallest lexicographical string after performing each of the following operations N times in any order:Remove the...
read more
Misc
Strings
Stack
Greedy
Mathematical
DSA
lexicographic-ordering
Maximum count of integers to be chosen from given two stacks having sum at most K
Last Updated: 23 July 2025
Given two stacks stack1[] and stack2[] of size N and M respectively and an integer K, The task is to count the maximum number of integers from two stacks having sum less t...
read more
Misc
Stack
Greedy
Searching
Mathematical
DSA
Arrays
Binary Search
prefix-sum
C++ Program For Arranging Single Linked List In Alternate Odd and Even Nodes Order
Last Updated: 23 July 2025
Given a singly linked list, rearrange the list so that even and odd nodes are alternate in the list.There are two possible forms of this rearrangement. If the first data i...
read more
Linked List
Stack
C++ Programs
DSA
Linked Lists
1
2
3
4
...
18