# Category Archives: Dynamic Programming

## Modify array to maximize sum of adjacent differences

Given an array, we need to modify values of this array in such a way that sum of absolute differences between two consecutive elements is… Read More »

## Count of strings that can be formed using a, b and c under given constraints

Given a length n, count the number of strings of length n that can be made using ‘a’, ‘b’ and ‘c’ with at-most one ‘b’… Read More »

## Highway Billboard Problem

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 Problem

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 elements

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 n

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 row

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 LIS

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 Coins

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 bits

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 machines

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 Problem

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 Array

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 Problem

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.

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 »