Given a n*m binary matrix, the task is to make an equal number of 1’s in each row using the operation as follows: Choose any… Read More
Category Archives: Greedy
Given two integers N and X. Find the maximum product of digits of N, such that increment any digit by 1 at most X times… Read More
Given array A[] of size N and integer X, the task is to find the minimum number of operations to make any two elements equal… Read More
Given an array arr[] of size N, the array represents N / 2 coordinates of a rectangle randomly shuffled with its X and Y coordinates.… Read More
Given a string str and an integer K, the task is to find the longest string that can be made by deleting letters from the… Read More
Given a string s of length N consisting of digits from 0 to 9. Find the lexicographically minimum sequence that can be obtained from given… Read More
Given an array arr[] of size N. Make the array arr[] sorted in non-decreasing order in the minimum number of operations where you can choose… Read More
You are given N and an integer X, where N represents the number of dice. You have to arrange those dices in such a way… Read More
What is the Greedy-Best-first search algorithm? Greedy Best-First Search is an AI search algorithm that attempts to find the most promising path from a given… Read More
Given an array arr[] of size N consisting only of 0s and 1s, the task is to find the minimum number of operations required to… Read More
Given an undirected graph with N nodes (numbered from 0 to N-1) such that any node can be reached from any other node and there… Read More
Given a string S of length N, the task is to find the minimum number of moves required to make a string palindrome where in… Read More
Find the count of numbers between L and R and are coprime with P. Note: Two numbers X and Y are coprime with each other… Read More
Construct a matrix whose each row contains N 1’s and each column contains M 1’s. Examples: Input: N = 3, M = 4Output:1 1 11… Read More
Given two arrays X[] and Y[] of length N each. You can shift from X[] to Y[] at most once. The task is to output… Read More