# Tag Archives: priority-queue

## K most occurring strings

Given an array arr[] of N strings and an integer K, the task is to print K strings which occurred the most number of times… Read More »

## Check if Array elements can be maximized upto M by adding all elements from another array

Given a positive integer M and two arrays arr[] and value[] of N and K positive integers respectively, the task is to add every element… Read More »

## 0/1 Knapsack using Least Count Branch and Bound

Given N items with weights W[0..n-1], values V[0..n-1] and a knapsack with capacity C, select the items such that: The sum of weights taken into… 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 »

## 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 »

## 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 »

## Path with minimum XOR sum of edges in a directed graph

Given a directed graph with N nodes and E edges, a source S and a destination D nodes. The task is to find the path… Read More »

## Minimum difference between maximum and minimum value of Array with given Operations

Given an array arr[] and an integer K. The following operations can be performed on any array element: Multiply the array element with K. If… Read More »

## Priority Queue using Queue and Heapdict module in Python

Priority Queue is an extension of the queue with the following properties. An element with high priority is dequeued before an element with low priority.… Read More »

## Length of Smallest Subsequence such that sum of elements is greater than equal to K

Given an array arr[] of size N and a number K, the task is to find the length of the smallest subsequence such that the… Read More »

## Huffman Coding using Priority Queue

Prerequisite: Greedy Algorithms | Set 3 (Huffman Coding), priority_queue::push() and priority_queue::pop() in C++ STL Given a char array ch[] and frequency of each characters as… Read More »

## Maximize the profit after selling the tickets

Given an array seats[] where seat[i] is the number of vacant seats in the ith row in a stadium for a cricket match. There are… Read More »

## Find the maximum amount that can be collected by selling movie tickets

Given an integer N and an array seats[] where N is the number of people standing in a line to buy a movie ticket and… Read More »

## Queries to find the left-most given type integer in a binary array

Given a binary array arr[], the task is to design a data structure that supports the following operations in O(1). Type 1: Remove and print… Read More »

## XOR of K smallest prime and composite numbers from the given array

Given an array arr[] of N non-zero positive integers and an integer K, the task is to find the XOR of the K largest prime… Read More »