## Print All Leaf Nodes of a Binary Tree from left to right | Set-2 ( Iterative Approach )

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

## Check if the elements of stack are pairwise sorted

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 »

## Where is an object stored if it is created inside a block in C++?

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 »

## Next Smaller Element

Given an array, print the Next Smaller Element (NSE) for every element. The Smaller smaller Element for an element x is the first smaller element… Read More »

## Sudo Placement[1.3] | Playing with Stacks

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 »

## Sudo Placement[1.3] | Stack Design

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 »

## Maximum length of rod for Q-th person

Given lengths of n rods in an array a[]. If any person picks any rod, half of the longest rod (or (max + 1) /… Read More »

## Level order traversal in spiral form | Using one stack and one queue

Write a function to print spiral order traversal of a tree. For below tree, function should print 1, 2, 3, 4, 5, 6, 7. You… Read More »

## Program to reverse a string (Iterative and Recursive)

Given a string, write a recursive program to reverse it. Recommended: Please try your approach on {IDE} first, before moving on to the solution. Method… Read More »

## Range Queries for Longest Correct Bracket Subsequence Set | 2

Given a bracket sequence or in other words a string S of length n, consisting of characters ‘(‘ and ‘)’. Find length of the maximum… Read More »

## Level order traversal with direction change after every two levels

Given a binary tree, print the level order traversal in such a way that first two levels are printed from left to right, next two… Read More »

## Delete array elements which are smaller than next or become smaller

Given an array arr[] and a number k. The task is to delete k elements which are smaller than next element (i.e., we delete arr[i]… Read More »

## stack emplace() in C++ STL

Stacks are a type of container adaptors with LIFO(Last In First Out) type of working, where a new element is added at one end and… Read More »

## stack swap() in C++ STL

Stacks are a type of container adaptors with LIFO(Last In First Out) type of working, where a new element is added at one end and… Read More »

## Reverse individual words

Given a string str, we need to print reverse of individual words. Examples: Input : Hello World Output : olleH dlroW Input : Geeks for… Read More »