Skip to content

Tag Archives: cpp-priority-queue

Given an unsorted array and two numbers x and k, find k closest values to x.Examples:   Input : arr[] = {10, 2, 14, 4, 7,… Read More
Given a min-heap of size n, find the kth least element in the min-heap. Examples: Input : {10, 50, 40, 75, 60, 65, 45} k… Read More
Given an integer K and an array of integers arr, the task is to find the maximum element from the array and after every retrieval… Read More
Given an array of integers, find the k smallest numbers after deleting given elements. In case of repeating elements delete only one instance in the… Read More
Given an array of integers, find the k largest number after deleting the given elements. In case of repeating elements, delete one instance for every… Read More
Given a Binary tree, the task is to sort the particular path from to a given node of the binary tree. You are given a… Read More
Given an array of n elements, where each element is at most k away from its target position, devise an algorithm that sorts in O(n… Read More
The priority_queue :: value_type method is a builtin function in C++ STL which represents the type of object stored as an element in a priority_queue.… Read More
In C++, priority_queue implements heap. Below are some examples of creating priority queue of pair type. Max Priority queue (Or Max heap) ordered by first… Read More
Given an infinite stream of integers, find the k’th largest element at any point of time. It may be assumed that 1 <= k <=… Read More
Given k sorted arrays of possibly different sizes, merge them and print the sorted output.Examples:   Input: k = 3 arr[][] = { {1, 3}, {2,… Read More
Yes, in C++ priority_queue, we may have duplicate values. // C++ program to demonstrate that duplicate // values are allowed in a priority queue //… Read More
STL priority_queue is the implementation of Heap Data-structure. By default, it’s a max heap and we can easily use it for primitive datatypes. There are… Read More
Given an array a, your task is to convert it into a non-increasing form such that we can either increment or decrement the array value… Read More
Given a number num containing n digits. The problem is to find the next greater number using the same set of digits in num on… Read More