Implementation of Priority Queue in Javascript
Priority Queue is an extension of Queue having some properties as follows:...
read more
Important functions of STL Components in C++
...
read more
priority_queue::swap() in C++ STL
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....
read more
Minimize remaining array element by removing pairs and replacing them with their average
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....
read more
Minimize subtraction of Array elements to make X at most 0
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:...
read more
Length of the longest subsequence with negative sum of all prefixes
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....
read more
Maximum the value of a given expression for any pair of coordinates on a 2D plane
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)....
read more
Replace the middle element of the longest subarray of 0s from the right exactly K times
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....
read more
Farthest index that can be reached from the Kth index of given array by given operations
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:...
read more
Find the k smallest numbers after deleting given elements
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....
read more
Amazon Interview | Set 34
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....
read more
Maximize jobs that can be completed under given constraint
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:...
read more