GeeksforGeeks

A computer science portal for geeks

Browsing the tag Dynamic Programming

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 intgers in the subsequence are sorted in increasing order.

Read More »

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

Read More »

Given a sequence, find the length of the longest palindromic subsequence in it. For example, if the given sequence is “BBABCBCAB”, then the output should be 7 as “BABCBAB” is the longest palindromic subseuqnce in it.

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.

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 »

Following are common definition of Binomial Coefficients. 1) A binomial coefficient C(n, k) can be defined as the coefficient of X^k in the expansion of (1 + X)^n.

Read More »

Given a sequence of matrices, find the most efficient way to multiply these matrices together.

Read More »

Given a value N, if we want to make change for N cents, and we have infinite supply of each of S = { S1, S2, .. , Sm} valued coins, how many ways can we make the change? The order of coins doesn’t matter.

Read More »

Given an array of integers where each element represents the max number of steps that can be made forward from that element. Write a function to return the minimum number of jumps to reach the end of the array (starting from the first element).

Read More »

Given a string, find the length of the longest substring without repeating characters. For example,

Read More »

Given a cost matrix cost[][] and a position (m, n) in cost[][], write a function that returns cost of minimum cost path to reach (m, n) from (0, 0). Each cell of the matrix represents a cost to traverse through that cell.

Read More »

Continuing further on dynamic programming series, edit distance is an interesting algorithm.

Read More »

We have discussed Overlapping Subproblems and Optimal Substructure properties in Set 1 and Set 2 respectively.

Read More »

We have discussed Overlapping Subproblems and Optimal Substructure properties in Set 1 and Set 2 respectively.

Read More »

As we discussed in Set 1, following are the two main properties of a problem that suggest that the given problem can be solved using Dynamic programming.

Read More »

Dynamic Programming is an algorithmic paradigm that solves a given complex problem by breaking it into subproblems and stores the results of subproblems to avoid computing the same results again.

Read More »

The Fibonacci numbers are the numbers in the following integer sequence.

Read More »

Given a binary matrix, find out the maximum size square sub-matrix with all 1s. For example, consider the below binary matrix.

Read More »

Ugly numbers are numbers whose only prime factors are 2, 3 or 5. The sequence 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, … shows the first 11 ugly numbers. By convention, 1 is included. Write a program to find and print the 150′th ugly number.

Read More »

Write an efficient C program to find the sum of contiguous subarray within a one-dimensional array of numbers which has the largest sum. Kadane’s Algorithm:

Read More »