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… Read More

# Category Archives: Stack

Given an array arr[] consisting of N integers, where each array element represents the height of a building situated on the X co-ordinates, the task… Read More

Given a stack S and an integer N, the task is to insert N at the bottom of the stack. Examples: Input: N = 7S =… Read More

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… Read More

Given a Stack consisting of N elements, the task is to reverse the Stack using an extra stack. Examples: Input: stack = {1, 2, 3,… Read More

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:… Read More

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… Read More

Given a string S and integers P and Q, which denotes the cost of removal of substrings “ab” and “ba” respectively from S, the task… Read More

Given two Stacks S1 and S2, the task is to check if both the stacks are equal or not in the same order without losing… Read More

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… Read More

Given a 2D array grid[][] of dimension N * M, the task is to perform the Depth – First Search traversal on the given 2D… Read More

Given an array arr[] consisting of N strings, the task is to find the total sum of the array brr[] (initially empty) constructed by performing… Read More

Given a Binary Tree consisting only ‘(‘ and ‘)’ a level is considered to be balanced if the nodes of the level having parenthesis are… Read More

Given a binary tree, the task is to print the inorder traversal of the modified tree obtained after shifting all the nodes of the given… Read More

Given string str of length N, consisting of pairs of balanced parentheses, the task is to calculate the score of the given string based on… Read More