# Category Archives: Greedy

Given an arr[] of length N. Then the task is to find minimum steps to make all the elements of the given array equal. Two… Read More
Given an array arr[] consisting of N non-negative integers. The task is to find a rearrangement of the array such that the prefix OR for… Read More
Given an array arr[] of size N and you need to fill another empty array of size N with positive integers. Each element in the… Read More
Given an integer N (N ≥ 5) Then assume you have two infinite arrays X and Y where X[] is an array of element N… Read More
Given an array A[] of size N. In one operation only one subarray can be selected and replaced with the sum of the subarray. The… Read More
Given N points moving along the X axis to the right whose initial position and speed are given in two arrays X[] (sorted in increasing… Read More
Given integer N, the task is to print an upside-down triangle where the left half is made of elements in the range [1, N*(N+1)/2] and… Read More
Given a list of words followed by two words, the task is to find the minimum distance between the given two words in the list… Read More
Given a matrix of dimension N*N whose all cells are initially 0. You are given Q queries, each of type {a, b, c, d} where… Read More
Given a string S of length N, the task is to find two non-intersecting strings of equal length such that the sum of absolute differences… Read More
Given a string S of size N consisting of characters from ‘0’to ‘9’, the task is to minimize the length of the string where In… Read More
Greedy Algorithm: Greedy algorithm is defined as a method for solving optimization problems by taking decisions that result in the most evident and immediate benefit… Read More
Given a string S consisting of only lowercase characters, the task is to find the lexicographically smallest string after removing exactly K characters from the… Read More
Divide and conquer Algorithm: Divide and Conquer is an algorithmic paradigm in which the problem is solved using the Divide, Conquer, and Combine strategy. A… Read More
Given two arrays X[] and Y[] of length N each. You can make a pair by selecting exactly one element from X[] and Y[]. The… Read More