# Category Archives: Dynamic Programming

## Highway Billboard ProblemMarch 13, 2017

Consider a highway of M miles. The task is to place billboards on the highway such that revenue is maximized. The possible sites for billboards… Read More »

## Gold Mine ProblemMarch 4, 2017

Given a gold mine of n*m dimensions. Each field in this mine contains a positive integer which is the amount of gold in tons. Initially… Read More »

## Finding the maximum square sub-matrix with all equal elementsMarch 2, 2017

Given a N x N matrix, determine the maximum K such that K x K is a submatrix with all equal elements i.e., all the… Read More »

## Number of subsequences in a string divisible by nFebruary 27, 2017

Given a string consisting of digits 0-9, count the number of subsequences in it divisible by m. Examples: Input : str = “1234”, n =… Read More »

## Maximum path sum that starting with any cell of 0-th row and ending with any cell of (N-1)-th rowFebruary 25, 2017

Given a N X N matrix Mat[N][N] of positive integers. There are only three possible moves from a cell (i, j) (i+1, j) (i+1, j-1)… Read More »

## Size of array after repeated deletion of LISFebruary 23, 2017

Given an array arr[0..n-1] of positive element. The task is to print remaining elements of arr[] after repeated deletion of LIS (of size greater than… Read More »

## Probability of getting at least K heads in N tosses of CoinsFebruary 21, 2017

Given N number of coins, the task is to find probability of getting at least K number of heads after tossing all the N coins… Read More »

## Count binary strings with k times appearing adjacent two set bitsFebruary 20, 2017

Given two integers n and k, count the number of binary strings of length n with k as number of times adjacent 1’s appear. Examples:… Read More »

## Check if all people can vote on two machinesFebruary 19, 2017

There are n people and two identical voting machines. We are also given an array a[] of size n such that a[i] stores time required… Read More »

## Friends Pairing ProblemFebruary 18, 2017

Given n friends, each one can remain single or can be paired up with some other friend. Each friend can be paired only once. Find… Read More »

## Minimum Sum Path In 3-D ArrayFebruary 17, 2017

Given a 3-D array arr[l][m][n], the task is to find the minimum path sum from the first cell of array to the last cell of… Read More »

## Printing brackets in Matrix Chain Multiplication ProblemFebruary 12, 2017

Prerequisite : Dynamic Programming | Set 8 (Matrix Chain Multiplication) Given a sequence of matrices, find the most efficient way to multiply these matrices together.… Read More »

## Maximum path sum in a triangle.February 9, 2017

We have given numbers in form of triangle, by starting at the top of the triangle and moving to adjacent numbers on the row below,… Read More »

## Maximum points collected by two persons allowed to meet once

Given a 2-D matrix A[N][M] where A[i][j] denotes the points available on this cell. Two persons, P1 and P2, start from two corners of this… Read More »

## Count of AP (Arithmetic Progression) Subsequences in an arrayFebruary 8, 2017

Given an array of n positive integers. The task is to count the number of Arithmetic Progression subsequence in the array. Note: Empty sequence or… Read More »