Top "Dynamic-programming" questions

Dynamic programming is an algorithmic technique for efficiently solving problems with a recursive structure containing many overlapping subproblems.

Optimal way of filling 2 knapsacks?

The dynamic programming algorithm to optimally fill a knapsack works well in the case of one knapsack. But is there …

algorithm dynamic-programming graph-algorithm knapsack-problem
Check if the given string follows the given pattern

A friend of mine just had his interview at Google and got rejected because he couldn't give a solution to …

string algorithm dynamic-programming graph-algorithm
Maximum Contiguous Subsequence Sum of At Least Length L

So for the following array, where L = 3 -5 -1 2 -3 0 -3 3 The best possible sum of at least length 3 would …

algorithm dynamic-programming arrays
Throwing cats out of windows

Imagine you're in a tall building with a cat. The cat can survive a fall out of a low story …

algorithm language-agnostic dynamic-programming asymptotic-complexity
Algorithm to Divide a list of numbers into 2 equal sum lists

There is a list of numbers. The list is to be divided into 2 equal sized lists, with a minimal difference …

python algorithm dynamic-programming np-complete knapsack-problem
Number of substrings in a string: n-squared or exponential

How many subtrings are there in a string in general? Why does string x [1:n] have O(n^2) subtrings according …

algorithm dynamic-programming combinatorics
How to understand the dynamic programming solution in linear partitioning?

I'm struggling to understand the dynamic programming solution to linear partitioning problem. I am reading the The Algorithm Design Manual …

algorithm partitioning dynamic-programming
Given an array of integers, find the LARGEST number using the digits of the array such that it is divisible by 3

E.g.: Array: 4,3,0,1,5 {Assume all digits are >=0. Also each element in array correspond to a digit. i.e. each …

algorithm dynamic-programming greedy
Smallest number that can not be formed from sum of numbers from array

This problem was asked to me in Amazon interview - Given a array of positive integers, you have to find …

arrays algorithm data-structures dynamic-programming subset-sum
Generate 10-digit number using a phone keypad

Given a phone keypad as shown below: 1 2 3 4 5 6 7 8 9 0 How many different 10-digit numbers can be formed starting from 1? The constraint is …

algorithm dynamic-programming keypad