# Category Archives: Greedy

## Maximum trains for which stoppage can be providedNovember 21, 2017

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 movesNovember 14, 2017

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 AlgorithmNovember 11, 2017

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 arraysNovember 8, 2017

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 MinimizationNovember 1, 2017

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 arrayOctober 25, 2017

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 numbersOctober 19, 2017

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]*iOctober 15, 2017

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 timesOctober 14, 2017

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 thievesOctober 9, 2017

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 lockOctober 8, 2017

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 AlgorithmsOctober 4, 2017

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 timeSeptember 24, 2017

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 »

## Operating System | Program for Next Fit algorithm in Memory ManagementSeptember 13, 2017

Prerequisite: Partition allocation methods What is Next Fit ? Next fit is a modified version of ‘first fit’. It begins as first fit to find… Read More »