# Category Archives: Greedy

## Minimum initial vertices to traverse whole matrix with given conditions

We are given a matrix that contains different values in its each cell. Our aim is to find the minimal set of positions in the… Read More »

## Maximum trains for which stoppage can be provided

We are given n-platform and two main running railway track for both direction. Trains which needs to stop at your station must occupy one platform… Read More »

## Array element moved by k using single moves

Given a list of n integers containing numbers 1-n in a shuffled way and a integer K. N people are standing in a queue to… Read More »

## Program for Optimal Page Replacement Algorithm

Prerequisite: Page Replacement Algorithms In operating systems, whenever a new page is referred and not present in memory, page fault occurs and Operating System replaces… Read More »

## Minimum sum of product of two arrays

Find the minimum sum of Products of two arrays of the same size, given that k modifications are allowed on the first array. In each… Read More »

## Job Sequencing Problem – Loss Minimization

We are given N jobs numbered 1 to N. For each activity, let Ti denotes the number of days required to complete the job. For… Read More »

## Minimum sum by choosing minimum of pairs from array

Given an array A[] of n-elements. We need to select two adjacent elements and delete the larger of them and store smaller of them to… Read More »

## Split n into maximum composite numbers

Given n, print the maximum number of composite numbers that sum up to n. First few composite numbers are 4, 6, 8, 9, 10, 12,… Read More »

## Maximize the sum of arr[i]*i

Given an array of N integers. You are allowed to rearrange the element of the array. The task is to find the maximum value of… Read More »

## Lexicographically largest subsequence such that every character occurs at least k times

Given a string S and an integer K. The task is to find lexicographically largest subsequence of S, say T, such that every character in… Read More »

## Policemen catch thieves

Given an array of size n that has the following specifications: Each element in the array contains either a policeman or a thief. Each policeman… Read More »

## Minimum rotations to unlock a circular lock

You are given a lock which is made up of n-different circular rings and each ring has 0-9 digit printed serially on it. Initially all… Read More »

## Correctness of Greedy Algorithms

A greedy algorithm selects a candidate greedily (local optimum) and adds it to the current solution provided that it doesn’t corrupt the feasibility. If the… Read More »

## Job Scheduling with two jobs allowed at a time

We are given N jobs, and their starting and ending times. We can do two jobs simultaneously at a particular moment. If one job ends… Read More »

## Buy Maximum Stocks if i stocks can be bought on i-th day

In a stock market, there is a product with its infinite stocks. The stock prices are given for N days, where arr[i] denotes the price… Read More »