# Category Archives: Dynamic Programming

## Dynamic Programming | Set 26 (Largest Independent Set Problem)February 17, 2013

Given a Binary Tree, find size of the Largest Independent Set(LIS) in it. A subset of all tree nodes is an independent set if there… Read More »

## Dynamic Programming | Set 25 (Subset Sum Problem)December 24, 2012

Given a set of non-negative integers, and a value sum, determine if there is a subset of the given set with sum equal to given… Read More »

## Dynamic Programming | Set 24 (Optimal Binary Search Tree)December 14, 2012

Given a sorted array keys[0.. n-1] of search keys and an array freq[0.. n-1] of frequency counts, where freq[i] is the number of searches to… Read More »

## Dynamic Programming | Set 23 (Bellman–Ford Algorithm)December 1, 2012

Given a graph and a source vertex src in graph, find shortest paths from src to all vertices in the given graph. The graph may… Read More »

## Longest Palindromic Substring | Set 1October 14, 2012

Given a string, find the longest substring which is palindrome. For example, if the given string is “forgeeksskeegfor”, the output should be “geeksskeeg”.

## Dynamic Programming | Set 22 (Box Stacking Problem)September 24, 2012

You are given a set of n types of rectangular 3-D boxes, where the i^th box has height h(i), width w(i) and depth d(i) (all… Read More »

## Dynamic Programming | Set 21 (Variations of LIS)September 15, 2012

We have discussed Dynamic Programming solution for Longest Increasing Subsequence problem in this post and a O(nLogn) solution in this post.

## Dynamic Programming | Set 20 (Maximum Length Chain of Pairs)September 1, 2012

You are given n pairs of numbers. In every pair, the first number is always smaller than the second number.

## Dynamic Programming | Set 19 (Word Wrap Problem)August 21, 2012

Given a sequence of words, and a limit on the number of characters that can be put in one line (line width). Put line breaks… Read More »

## Dynamic Programming | Set 18 (Partition problem)July 4, 2012

Partition problem is to determine whether a given set can be partitioned into two subsets such that the sum of elements in both subsets is… Read More »

## Dynamic Programming | Set 17 (Palindrome Partitioning)June 17, 2012

Given a string, a partitioning of the string is a palindrome partitioning if every substring of the partition is a palindrome.

## Dynamic Programming | Set 16 (Floyd Warshall Algorithm)June 7, 2012

The Floyd Warshall Algorithm is for solving the All Pairs Shortest Path problem. The problem is to find shortest distances between every pair of vertices… Read More »

## Dynamic Programming | Set 15 (Longest Bitonic Subsequence)June 6, 2012

Given an array arr[0 … n-1] containing n positive integers, a subsequence of arr[] is called Bitonic if it is first increasing, then decreasing. Write… Read More »

## Dynamic Programming | Set 14 (Maximum Sum Increasing Subsequence)May 15, 2012

Given an array of n positive integers. Write a program to find the sum of maximum sum subsequence of the given array such that the… Read More »

## Dynamic Programming | Set 13 (Cutting a Rod)May 11, 2012

Given a rod of length n inches and an array of prices that contains prices of all pieces of size smaller than n.