Courses
Tutorials
Practice
Data Structure
Java
Python
HTML
Interview Preparation
DSA
Practice Problems
C
C++
Java
Python
JavaScript
Data Science
Machine Learning
Courses
Linux
DevOps
SQL
Web Development
System Design
Aptitude
GfG Premium
Similar Topics
Web Technologies
37.4K+ articles
DSA
22.8K+ articles
Misc
8.8K+ articles
C++
4.3K+ articles
Competitive Programming
3.3K+ articles
Strings
3.3K+ articles
STL
1.3K+ articles
Data Structures
1.1K+ articles
Stack
436+ articles
cpp-stack
79+ articles
cpp-stack-functions
29 posts
Recent Articles
Popular Articles
Print prime factors of a given integer in decreasing order using Stack
Last Updated: 18 June 2021
Given an integer N, the task is to print prime factors of N in decreasing order using the stack data structure.Examples:Input: N = 34Output:17 2Explanation:The prime facto...
read more
Searching
Mathematical
Competitive Programming
DSA
prime-factor
cpp-stack-functions
Check if a given string can be converted to a Balanced Bracket Sequence
Last Updated: 31 May 2022
Given a string S of size N consisting of '(', ')', and '$', the task is to check whether the given string can be converted into a balanced bracket sequence by replacing ev...
read more
Strings
Stack
Algorithms
Data Structures
DSA
interview-preparation
cpp-stack-functions
Minimize length of a string by removing pairs of consecutive increasing or decreasing digits
Last Updated: 10 June 2021
Given a numeric string S consisting of N digits, the task is to find the minimum length of the string that can be formed by repeatedly removing pairs of adjacent consecuti...
read more
Strings
Stack
Algorithms
Data Structures
DSA
substring
cpp-stack-functions
Minimize length of a given string by removing subsequences forming valid parenthesis
Last Updated: 22 November 2021
Given a string S consisting of characters '(', ')', '[', ']', '{', '}', the task is to remove all balanced bracket subsequences from the string and print the remaining cha...
read more
Strings
Stack
DSA
subsequence
cpp-stack-functions
Implementing Stack Using Class Templates in C++
Last Updated: 02 February 2022
The task is to implement some important functions of stack like pop(), push(), display(), topElement(), isEmpty(), isFull() using class template in C++. Stack is a linear ...
read more
Stack
C++
DSA
Templates
cpp-stack-functions
Check if a string is a subsequence of another string ( using Stacks )
Last Updated: 07 November 2023
Given a string S, the task is to check if the string target is a subsequence of string S or not, using a Stack.Examples:Input: S = ”KOTTAYAM”, target = ”KOTA”Output: YesEx...
read more
Strings
Stack
DSA
subsequence
cpp-stack-functions
Remove trailing zeros from the sum of two numbers ( Using Stack )
Last Updated: 06 March 2022
Given two numbers A and B, the task is to remove the trailing zeros present in the sum of the two given numbers using a stack.Examples:Input: A = 124, B = 186Output: 31Exp...
read more
Stack
Mathematical
DSA
number-digits
cpp-stack-functions
Program to insert an element at the Bottom of a Stack
Last Updated: 15 April 2025
Given a stack s containing n integers and an integer x, the task is to insert the element x at the bottom of the stack.Examples:Input:x = 7s = 1 - (Top) 2 3 4 5Output:...
read more
Stack
Recursion
Data Structures
DSA
cpp-stack
cpp-stack-functions
Reversing a Stack with the help of another empty Stack
Last Updated: 30 November 2023
Given a Stack consisting of N elements, the task is to reverse the Stack using an extra stack.Examples:Input: stack = {1, 2, 3, 4, 5}Output:12345Explanation:Input Stack:54...
read more
Stack
DSA
Reverse
cpp-stack-functions
Subsequence of size 3 with 3rd greater than the 1st and snaller than 2nd
Last Updated: 26 April 2025
You are given an array arr of size n, where each element represents the height of a building positioned along the x-axis. Your task is to determine whether it is possible ...
read more
Misc
Stack
Mathematical
DSA
Arrays
cpp-stack
cpp-stack-functions
Clone a stack without using extra space | Set 2
Last Updated: 08 July 2024
Given a stack S, the task is to copy the content of the given stack S to another stack T maintaining the same order.Examples:Input: Source:- |5| |4| ...
read more
Stack
Recursion
Data Structures
DSA
cpp-stack
cpp-stack-functions
Design a dynamic stack using arrays that supports getMin() in O(1) time and O(1) extra space
Last Updated: 27 August 2021
Design a special dynamic Stack using an array that supports all the stack operations such as push(), pop(), peek(), isEmpty(), and getMin() operations in constant Time and...
read more
Stack
Data Structures
DSA
interview-preparation
cpp-stack
cpp-stack-functions
System-Design
Reversing a Stack using two empty Stacks
Last Updated: 24 August 2021
Given a stack S, the task is to reverse the stack S using two additional stacks.Example:Input: S={1, 2, 3, 4, 5}Output: 5 4 3 2 1Explanation:The initial stack S:1→top2345A...
read more
Stack
DSA
Reverse
cpp-stack
cpp-stack-functions
How to Check if a Stack is Empty in C++?
Last Updated: 12 March 2024
In C++, we have a stack data structure that follows a LIFO (Last In First Out) rule of operation. In this article, we will learn how to check if a stack is empty in C++.Ex...
read more
C++ Programs
C++
Picked
STL
cpp-stack
cpp-stack-functions
CPP Examples
How to Reverse a Stack in C++?
Last Updated: 22 March 2024
In C++, stacks are containers that store the elements in the last in-first out order(LIFO). In, this article, we will learn how we can reverse a stack in C++.ExampleInput:...
read more
C++ Programs
C++
Picked
STL
cpp-stack
cpp-stack-functions
CPP Examples
1
2
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our
Cookie Policy
&
Privacy Policy
Got It !