Skip to content

Tag Archives: cpp-stack

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
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 contains… 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 increasing,… Read More
There are two parts of memory in which an object can be stored: stack – Memory from the stack is used by all the members… Read More
Given an array, print the Next Smaller Element (NSE) for every element. The NSE for an element x is the first smaller element on the… Read More
You are given 3 stacks, A(Input Stack), B(Auxiliary Stack) and C(Output Stack). Initially stack A contains numbers from 1 to N, you need to transfer… Read More
Given q number of queries, you need to perform operations on the stack. Queries are of three types 1, 2, and 3. If the operation… Read More

Start Your Coding Journey Now!