Tag Archives: cpp-stack

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 change 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
C++ filter_none edit close play_arrow link brightness_4 code // C++ code #include <iostream> #include <utility> using namespace std;   int main() {     // Declaring the… Read More
Given an array arr[] of size N and integer Y, the task is to find a minimum of all the differences between the maximum and… Read More
Given a binary tree of N nodes, the task is to print level order traversal in a spiral form. In spiral form, nodes at the… Read More
Given two Stacks, the task is to check if the given stacks are same or not. Two stacks are said to be same if they… Read More
We have seen different ways of performing postorder traversal on Binary Trees. Post Order Traversal. Iterative Postorder Traversal using Two Stacks. Iterative Postorder Traversal using… Read More
Given a Binary Tree, the task is to print the leaf nodes from left to right. The nodes must be printed in the order they… Read More
Given a stack of integers, write a function pairWiseSorted() that checks whether numbers in the stack are pairwise sorted or not. The pairs must be… Read More