# Category Archives: Greedy

## Minimize Cash Flow among a given set of friends who have borrowed money from each other

Given a number of friends who have to give or take some amount of money from one another. Design an algorithm by which the total… Read More »

## Job Sequencing Problem

Given an array of jobs where every job has a deadline and associated profit if the job is finished before the deadline. It is also… Read More »

## Minimum Number of Platforms Required for a Railway/Bus Station

Given arrival and departure times of all trains that reach a railway station, the task is to find the minimum number of platforms required for… Read More »

## MakeMyTrip Interview Experience | Set 2 (On-Campus)

MakeMyTrip recently visited our campus.Below is my interview experience: Round 1: (Online MCQs) Section A- There were 20 Aptitude and Logical Reasoning questions which has… Read More »

## Connect n ropes with minimum cost

There are given n ropes of different lengths, we need to connect these ropes into one rope. The cost to connect two ropes is equal… Read More »

## Rearrange a string so that all same characters become d distance away

Given a string and a positive integer d. Some characters may be repeated in the given string. Rearrange characters of the given string such that… Read More »

## Graph Coloring | Set 2 (Greedy Algorithm)

We introduced graph coloring and applications in previous post. As discussed in the previous post, graph coloring is widely used. Unfortunately, there is no efficient… Read More »

## Dijkstra’s Algorithm for Adjacency List Representation | Greedy Algo-8

We recommend reading the following two posts as a prerequisite of this post. 1. Greedy Algorithms | Set 7 (Dijkstra’s shortest path algorithm) 2. Graph and… Read More »

## Dijkstra’s shortest path algorithm | Greedy Algo-7

Given a graph and a source vertex in the graph, find shortest paths from source to all vertices in the given graph. Dijkstra’s algorithm is… Read More »

## Prim’s MST for Adjacency List Representation | Greedy Algo-6

We recommend to read following two posts as a prerequisite of this post. 1. Greedy Algorithms | Set 5 (Prim’s Minimum Spanning Tree (MST)) 2.… Read More »

## Prim’s Minimum Spanning Tree (MST) | Greedy Algo-5

We have discussed Kruskal’s algorithm for Minimum Spanning Tree. Like Kruskal’s algorithm, Prim’s algorithm is also a Greedy algorithm. It starts with an empty spanning tree.… Read More »

## Efficient Huffman Coding for Sorted Input | Greedy Algo-4

We recommend to read following post as a prerequisite for this. Greedy Algorithms | Set 3 (Huffman Coding) Time complexity of the algorithm discussed in… Read More »

## Kruskal’s Minimum Spanning Tree Algorithm | Greedy Algo-2

What is Minimum Spanning Tree? Given a connected and undirected graph, a spanning tree of that graph is a subgraph that is a tree and… Read More »

## Maximum Length Chain of Pairs | DP-20

You are given n pairs of numbers. In every pair, the first number is always smaller than the second number. A pair (c, d) can… Read More »