Given an array arr[] of length N. You can perform at most K operations on the array of the following type: Choose an index i… Read More
Category Archives: Greedy
Given an integer arr[] of length N such that (Ai > 0) for all (1 ≤ i ≤ N) and an integer X. In one… Read More
Given two numbers N and K, and a pair A and B, the task is to multiply N by A or B as many times… Read More
Given an array stream of n integers in the form of a stream, the task is to find the minimum number of operations that are… Read More
A greedy algorithm is an algorithmic paradigm that follows the problem-solving heuristic of making the locally optimal choice at each stage with the hope of… Read More
Given an integer array Arr[] of length N and an array Queries[] of length Q where Queries[i] = [valuei, indexi]. For each query i, update… Read More
Given a binary string S of even size that contains only 0s and 1s, the task is to find the minimum flips (that is 0… Read More
Given an N×N Matrix Mat[][] of N rows and N columns. There is exactly one Queen on the chessboard and the cell that is under… Read More
Geek has N packs of chocolates and the amount of chocolates in each pack is given in an array arr[]. His sister wants to have… Read More
Given two arrays A[] and B[] of size N and M respectively denoting the required elements of each group and the number of elements in… Read More
Given two arrays A[] and B[] of size N each, the task is to find the number of elements in array B[] that occur before… Read More
Given a 2-D array A[][] of size N × 3, where each element of the array is of the form {x, y, z}, where x,… Read More
Given an array arr[] of length N, two arrays start[] and end[] of size M each where {start[i], end[i]} denotes a subarray of arr[] and… Read More
Given an array arr[] of N Positive integers, the task is to find the largest prefix sum which is also the suffix sum and prefix… Read More
Given a string S, the task is to find out the length of the smallest substring of S that needs to be rearranged so that… Read More