# Tag Archives: Greedy Algorithms

## Minimize operations required to make each element of Array equal to it’s index value

Given an array arr[] consisting of N integers, the task is to to modify the array such that arr[index] = index using minimum number of… Read More »

## Minimum sum obtained by choosing N number from given N pairs

Given an array arr[] of N pairs of integers (A, B) where N is even, the task is to find the minimum sum of choosing… Read More »

## Remove minimum characters from string to split it into three substrings under given constraints

Given a string str of lowercase alphabets, the task is to remove minimum characters from the given string so that string can be break into… Read More »

## Find the next greater element in a Circular Array

Given a circular array arr[] of N integers such that the last element of the given array is adjacent to the first element of the… Read More »

## Convert one array to another using adjacent swaps of elements

Given two arrays arr1[] and arr2[] of N integers. We can choose any two adjacent elements from array arr1[] and swap them if they are… Read More »

## Maximize the number of indices such that element is greater than element to its left

Given an array arr[] of N integers, the task is to maximize the number of indices such that an element is greater than the element… Read More »

## Find minimum changes required in an array for it to contain k distinct elements

Given an array arr of size N and a number K. The task is to find the minimum elements to be replaced in the array… Read More »

## Minimum number of Binary strings to represent a Number

Given a number N. The task is to find the minimum number of binary strings required to represent the given number as the sum of… Read More »

## Count distinct points visited on the number line

Given a person who is at position current_pos and a binary string path which is the moves the person took, if path[i] = ‘0’ then… Read More »

## Bitwise OR of N binary strings

Given an array arr[] of binary strings, the task is to calculate the bitwise OR of all of these strings and print the resultant string.… Read More »

## Find the number of boxes to be removed

Given an array arr[] representing a sequence of piles of boxes where each and every box has the same height of 1 unit. Given that… Read More »

## Maximum removal from array when removal time >= waiting time

Given there are N elements in an array. The task is to remove elements from the array from left to right. However, some time is… Read More »

## Minimum number of days required to complete the work

Given N works numbered from 1 to N. Given two arrays D1[] and D2[] of N elements each. Also, each work number W(i) is assigned… Read More »

## Subarray whose absolute sum is closest to K

Given an array of n elements and an integer K, the task is to find the subarray with minimum value of ||a[i] + a[i +… Read More »

## Minimum cost path from source node to destination node via an intermediate node

Given an undirected weighted graph. The task is to find the minimum cost of the path from source node to the destination node via an… Read More »