Skip to content

Category Archives: Greedy

Given three stacks of the positive numbers, the task is to find the possible equal maximum sum of the stacks with the removal of top… Read More
Given an array of digits (values are from 0 to 9), find the minimum possible sum of two numbers formed from digits of the array.… Read More
Given an array of size n and a number k. We must modify array K number of times. Here modify array means in each operation… Read More
Given a two dimensional grid, each cell of which contains integer cost which represents a cost to traverse through that cell, we need to find… Read More
Given a directed graph and a source node and destination node, we need to find how many edges we need to reverse in order to… Read More
A board of length m and width n is given, we need to break this board into m*n squares such that cost of breaking is… Read More
Given an array of size n and a number k. We must modify array K number of times. Here modify array means in each operation… Read More
Given a set of n jobs where each job i has a deadline di >=1 and profit pi>=0. Only one job can be scheduled at… Read More
How to find the largest number with given digit sum s and number of digits d?Examples:   Input : s = 9, d = 2 Output… Read More
How to find the smallest number with given digit sum s and number of digits d? Examples :   Input : s = 9, d = 2… Read More
Given heights of n towers and a value k. We need to either increase or decrease the height of every tower by k (only once)… Read More
Dijkstra’s shortest path algorithm runs in O(Elog V) time when implemented with adjacency list representation (See C implementation and STL based C++ implementations for details).… Read More
  Given weights and values of n items, we need to put these items in a knapsack of capacity W to get the maximum total… Read More
Given n items of different weights and bins each of capacity c, assign each item to a bin such that number of total used bins… Read More
Given an array of jobs with different time requirements. There are K identical assignees available and we are also given how much time an assignee… Read More