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
Category Archives: Greedy
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
Given a number N without leading 0s, the task is to find the maximum number formed after replacing any two adjacent digits by their sum… Read More
Given an integer N, the task is to find all the factors (excluding itself) of the number N and their XOR. Examples: Input: N =… Read More
Geek is organizing a party at his house. For the party, he needs exactly N (N ≤ 103) donuts for the guests. Geek decides to order the donuts from a… Read More