# Tag Archives: cpp-queue

## Find the Level of a Binary Tree with Width K

Given a Binary Tree and an integer K, the task is to find the level of the Binary Tree with width K. If multiple levels… Read More »

## Count of array elements whose order of deletion precedes order of insertion

Given an initial array, A[] and a final array B[] both of size N containing integers from the range [1, N], where A[] represent the… Read More »

## Important functions of STL Components in C++

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 »

## Count of prime factors of N to be added at each step to convert N to M

Given two integers N and M, the task is to find out smallest number of operations required to convert N to M. Each operation involves… Read More »

## Find the maximum cost path from the bottom-left corner to the top-right corner

Given a two dimensional grid, each cell of which contains integer cost which represents a cost to traverse through that cell. The task is to… Read More »

## Iterative approach to check for children sum property in a Binary Tree

Given a binary tree, write a function that returns true if the tree satisfies below property: For every node, data value must be equal to… Read More »

## Find the minimum positive integer such that it is divisible by A and sum of its digits is equal to B

Given two integers A and B, the task is to find the minimum positive integer N such that N is divisible by A and the… Read More »

## Iterative program to find distance of a node from root

Given the root of a binary tree and a key x in it, find the distance of the given key from the root node. Dis­tance… Read More »

## Check if Queue Elements are pairwise consecutive | Set-2

Given a Queue of integers. The task is to check if consecutive elements in the queue are pairwise consecutive.Examples:  Input: 1 2 5 6 9… Read More »

## Create a tree in level order

Given an array of elements, the task is to insert these elements in level order and construct a tree. Input : arr[] = {10, 20,… Read More »

## Sum of cousins of a given node in a Binary Tree

Given a binary tree and data value of a node. The task is to find the sum of cousin nodes of given node. If given… Read More »

## Sudo Placement[1.3] | Final Destination

Given an array of integers and a number K with initial and final values. Your task is to find the minimum number of steps required… 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 »

## Sum of nodes at maximum depth of a Binary Tree | Iterative Approach

Given a root node to a tree, find the sum of all the leaf nodes which are at maximum depth from the root node.Example:  1… Read More »