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

# Category Archives: Stack

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

Given a string S of length N, the task is to find the lexicographically smallest K-length subsequence from the string S (where K < N). … Read More

Given a binary string str, the task is to check if the string can be emptied by removing all subsequences of the form “10” Examples:… Read More

Given a binary tree, the task is to print all the nodes of the binary tree in Pre-order, Post-order, and In-order iteratively using only one… Read More