# Category Archives: Dynamic Programming

## Largest divisible pairs subset

Given an array of n distinct elements, find length of the largest subset such that every pair in the subset is such that the larger… Read More »

## Maximum sum path in a matrix from top to bottom

Consider a n*n matrix. Suppose each cell in the matrix has a value assigned. We can go from each cell in row i to a… Read More »

## Minimum cost to make two strings identical by deleting the digits

Given two strings X and Y consisting of only digits ‘0’ to ‘9’. Find minimum cost required to make the given two strings identical. Only… Read More »

## Maximum size subset with given sum

This is an extended version of subset sum problem. Here we need to find size of maximum size subset whose sum is equal to given… Read More »

## Minimum jumps to reach last building in a matrix

Given a matrix containing an integer value, In which each cell of the matrix represents height of building. Find minimum jumps needed reach from First… Read More »

## Number of n digit stepping numbers

Given n, find count of n digit Stepping numbers. A number is called stepping number if all adjacent digits have an absolute difference of 1.… Read More »

## Print Longest Palindromic Subsequence

Given a sequence, print a longest palindromic subsequence of it. Examples : Input : BBABCBCAB Output : BABCBAB The above output is the longest palindromic… Read More »

## Program for Bridge and Torch problem

Given an array of positive distinct integer denoting the crossing time of ‘n’ people. These ‘n’ people are standing at one side of bridge. Bridge… Read More »

## The painter’s partition problem

We have to paint n boards of length {A1, A2…An}. There are k painters available and each takes 1 unit time to paint 1 unit… Read More »

## Given a large number, check if a subsequence of digits is divisible by 8

Given a number of at most 100 digits. We have to check if it is possible, after removing certain digits, to obtain a number of… Read More »

## Minimum sum submatrix in a given 2D array

Given a 2D array, find the minimum sum submatrix in it. Examples: Input : M[][] = {{1, 2, -1, -4, -20}, {-8, -3, 4, 2,… Read More »

## Maximum sum subsequence with at-least k distant elements

Given an array and a number k, find a subsequence such that Sum of elements in subsequence is maximum Indices of elements of subsequence differ… Read More »

## Number of NGEs to the right

Given an array of n integers and q queries, print the number of next greater elements to the right of the given index element. Examples:… Read More »

## Length of Longest Balanced Subsequence

Given a string S, find the length of longest balanced subsequence in it. A balanced string is defined as:- A Null string is a balanced… Read More »

## Tile Stacking Problem

A stable tower of height n is a tower consisting of exactly n tiles of unit height stacked vertically in such a way, that no… Read More »