Skip to content

Category Archives: Dynamic Programming

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
  Given a number n, print all primes smaller than or equal to n. It is also given that n is a small number.  Example: … Read More
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
Given a string, a partitioning of the string is a palindrome partitioning if every substring of the partition is a palindrome. For example, “aba|b|bbabb|a|b|aba” is… Read More
  The Floyd Warshall Algorithm is for solving the All Pairs Shortest Path problem. The problem is to find shortest distances between every pair of… Read More
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
Given an array of random numbers. Find longest increasing subsequence (LIS) in the array. I know many of you might have read recursive and dynamic programming… Read More
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
  Given a rod of length n inches and an array of prices that includes prices of all pieces of size smaller than n. Determine… Read More
  Given a sequence, find the length of the longest palindromic subsequence in it.  As another example, if the given sequence is “BBABCBCAB”, then the… Read More
The following is a description of the instance of this famous puzzle involving n=2 eggs and a building with k=36 floors.Suppose that we wish to… Read More
Given weights and values of n items, put these items in a knapsack of capacity W to get the maximum total value in the knapsack.… Read More
The following are the common definitions of Binomial Coefficients.  A binomial coefficient C(n, k) can be defined as the coefficient of x^k in the expansion… Read More
Given a sequence of matrices, find the most efficient way to multiply these matrices together. The problem is not actually to perform the multiplications, but… Read More
  Given a value N, if we want to make change for N cents, and we have infinite supply of each of S = {… Read More