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

# Tag Archives: cpp-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 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 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 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

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

Given an array arr[] of length N, the task is to modify the given array by replacing each element of the given array by its… Read More

Given an array of strings arr[] representing the changed folder operations(Unix-style) performed on the file system. Initially, the file system opens in the main folder.… Read More

Design the forward and backward buttons of a Browser using Stack Data Structure. If at any instance, the URL does not exist after pressing any… Read More

Given an array of strings Q[], consisting of queries of the following types: “WRITE X”: Write a character X into the document. “UNDO”: Erases the… Read More

Given an array arr[] of size N, the task is to print the distance of every array element from its next greater element. For array… Read More

Given an array A[] of N integers, the task is to find the relative rank for each element in the given array. The relative rank… Read More

Prerequisite: List, Stack Lists are sequence containers that allow non-contiguous memory allocation. As compared to vector, list has slow traversal, but once a position has… Read More

Given an array arr[], the task is to check that if there exist a triplet (i, j, k) such that arr[i]<arr[k]<arr[j] and i<j<k then print… Read More