Priority Queue is an extension of Queue having some properties as follows:...
Priority queues are a type of container adaptors, specifically designed such that the first element of the queue is either the greatest or the smallest of all elements in the queue. However, in C++ STL (by default) the largest element is at the top. We can also create a priority queue having the smallest element at the top by simply passing an extra parameter while creating the priority queue....
Given an array arr[] of size N, the task is to find the smallest possible remaining array element by repeatedly removing a pair, say (arr[i], arr[j]) from the array and inserting the Ceil value of their average....
Given a number X, and an array arr[] of length N containing the N numbers. The task is to find the minimum number of operations required to make X non-positive. In one operation:...
Given an array arr[] consisting of N integers, the task is to find the length of the longest subsequence such that the prefix sum at each index of the subsequence is negative....
Given a sorted 2D array arr[][2] of size N such that (arr[i][0], arr[i][1]) represents the coordinates of ith point in the cartesian plane and an integer K, the task is to find the maximum value of the expression (|arr[i][0] – arr[j][0]| + arr[i][1] + arr[j][1]) such that |arr[i][0] – arr[j][0]| ? K for any possible pair of coordinates (i, j)....
Given an array arr[] of size N, consisting of 0s initially, and a positive integer K, the task is to print the array elements by performing the following operations exactly K times....
Given an array arr[] consisting of N integers and three integers X, Y, and K, the task is to find the farthest index that can be reached by the following operations:...
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 given array for every instance of element present in the array containing the elements to be deleted....
First of all, a very very big thanks to whole team of geeks for geeks. It is because of them only that I was able to crack the interview process of amazon and get a job in my dream company....
Given an integer N denoting number of jobs and a matrix ranges[] consisting of a range [start day, end day] for each job within which it needs to be completed, the task is to find the maximum possible jobs that can be completed.Examples:...