Skip to main content

Questions tagged [dynamic-programming]

Dynamic programming builds solutions from solutions to simpler subproblems. It's closely allied to recursion, but dynamic programming algorithms are formulated as iteration usually over a very regular datastructure.

19 votes
5 answers
10k views

I have been reading up on dynamic programming lately. Would like to hear from someone who started from scratch and now is pretty good at identifying and solving DP problems. I am struggling in ...
user110036's user avatar
9 votes
3 answers
525 views

I've been bashing my skull at this problem for some time now, and its really starting to frustrate me. The problem is: I have a set of characters, A, B, C, and D. I have to tell in how many ways a ...
Olavi Mustanoja's user avatar
9 votes
2 answers
3k views

I recently came across this question: "You are given a boolean expression consisting of a string of the symbols 'true', 'false', 'and', 'or', and 'xor'. Count the number of ways to parenthesize the ...
newbie's user avatar
  • 93
9 votes
2 answers
6k views

Winkler's pizza picking problem: A circular pizza pie of n slices, where slice i has area S_i i.e, the area is different for each pie piece. Eaters Alice and Bob take turns picking slices, but it is ...
DrDeltaS's user avatar
8 votes
3 answers
1k views

Does there exist a dynamic programming algorithm to find the longest subsequence in a string X that does not contain Y as substring? Just that this problem seems so similar to other DP string ...
user83834's user avatar
7 votes
3 answers
534 views

Imagine we want to pick m numbers from n numbers so that the difference of the maximum and minimum of the m numbers be minimum, for example if m = 4 n =6 numbers: 10 12 10 7 5 22 The ...
Amen's user avatar
  • 135
7 votes
3 answers
9k views

I've seen numerous questions (and answers) concerning the number of binary strings (e.g "10010" containing some binary substring (e.g "00"). I'd like to know if there is a way to generalize this: ...
Meri Craig's user avatar
7 votes
1 answer
319 views

I've been thinking about this problem for a while, and I can only find a recursive solution but I'm feeling that there is a dynamic programming way to do it, I just can't figure it out. Is this a ...
Daniel Olsson's user avatar
6 votes
1 answer
686 views

I am working on a problem similar to the assembly line scheduling by dynamic programming.The issue is that unlike the classic problem where we have predefined stations now I only have information ...
user avatar
5 votes
3 answers
1k views

Came across this problem -- You are given a grid with numbers that represent the elevation at a particular point. From each box in the grid you can go north, south, east, west - but only if the ...
WeirdAl's user avatar
  • 79
5 votes
5 answers
1k views

I've started relying heavily on a mocking framework in php for my unit tests. My concern is that with a dynamic language, there is no way of enforcing a return type. When mocking, you have to ensure ...
GWed's user avatar
  • 3,263
5 votes
4 answers
3k views

Suppose I have a list of Ingredients In My Fridge which are going off soon, and a list of Recipes which use up various Ingredients. (Some of which I don't currently have.) Is there an algorithm which ...
Simon Cozens's user avatar
5 votes
5 answers
458 views

Concise problem definition: given n and {a,b,c}; (1 ≤ n, a, b, c ≤ 4000); Constraint -> a*i + b*j + c*k==n (i,j,k>=0); Objective-> maximize(i,j,k) Examples: n=47 and a=7,b=5,c=8 -> max=...
Humoyun Ahmad's user avatar
5 votes
2 answers
3k views

I have the following problem to solve: Given a ferry with length d and a list of n cars conataining their length we must load the cars on the ferry in an order in which they appear in the list on 2 ...
qiubit's user avatar
  • 205
5 votes
2 answers
1k views

Problem Statement - The task is to find the most profitable contiguous segment of tests, given a sequence of test scores, with being allowed to drop any k tests from a chosen range. The problem ...
7Aces's user avatar
  • 449

15 30 50 per page
1
2 3 4 5