# Category Archives: Queue

## 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 minimum number of operations required to convert N to M. Each operation involves… Read More »

## Minimum nodes to be colored in a Graph such that every node has a colored neighbour

Given a graph G with V nodes and E edges, the task is to colour no more than floor(V/2) nodes such that every node has… Read More »

## Check if it is possible to reach to the index with value K when start index is given

Given an array arr[] of N positive integers and two positive integers S and K, the task is to reach the position of the array… Read More »

## Check if the end of the Array can be reached from a given position

Given an array arr[] of N positive integers and a number S, the task is to reach the end of the array from index S.… Read More »

## Last element remaining by deleting two largest elements and replacing by their absolute difference if they are unequal

Given an array arr[] of N elements, the task is to perform the following operation: Pick the two largest element from the array and remove… Read More »

## Longest subarray whose elements can be made equal by maximum K increments

Given an array arr[] of positive integers of size N and a positive integer K, the task is to find the maximum possible length of… Read More »

## Maximum absolute difference between any two level sum in a Binary Tree

Given a Binary Tree having positive and negative nodes, the task is to find the maximum absolute difference of level sum in it. Examples: Input:… Read More »

## Real-time application of Data Structures

A data structure is a particular way of organizing data in a computer so that it can be used effectively. In this article, the real-time… Read More »

## Check if the given permutation is a valid BFS of a given Tree

Given a tree with N nodes numbered from 1 to N and an permutation array of numbers from 1 to N. Check if it is… Read More »

## Reduce the array to atmost one element by the given operations

Given an array of integers arr[], the task is to find the remaining element in the array after performing the following operations: In each turn,… Read More »

## Find the K closest points to origin using Priority Queue

Given a list of n points on 2D plane, the task is to find the K (k < n) closest points to the origin O(0,… Read More »

## Minimum number of operations required to set all elements of a binary matrix

Given a binary matrix mat[][] consisting of 1s and 0s of dimension M * N, the task is to find the number of operations to… Read More »

## Minimum circular rotations to obtain a given numeric string by avoiding a set of given strings

Given a numeric string target of length N and a set of numeric strings blocked, each of length N, the task is to find the… Read More »

## Priority queue of pairs in C++ with ordering by first and second element

Priority Queue: Priority queue is the extension of the queue in which elements associated with priority and elements having higher priority is popped first. Priority… Read More »

## Array value by repeatedly replacing max 2 elements with their absolute difference

Given an array arr size N, the task is to print the final array value remaining in the array when the maximum and second maximum… Read More »