Dynamic Programming patters implemented with
In this repo I'm going to collect families of Dynamic Programming problems and implement them in Typescript.
Bounded Problems (each item in the list can be used only once):
- Based on optimizing to some target:
- Backpack capacity. Given list of items' weights and items' profits. Need to calculate max profit by given backpack's max capacity
- Split array on equal sums. Hint: weights = profits = array. Capacity = array sum / 2.
- Find subset of array that gives some sum. Hint: weights = profits = array. Capacity = required sum.
- Split array on 2 parts with min difference in their sums. Hint: target capacity = array sum / 2. Result would be in bottom right cell.
- Based on finding number of wayt to get the target
- Number of array subsets that gives required sum.
- Given array of positive numbers and required sum. Need to assign + and - for each number in array to sum of elements gives S.Return number of ways to do it. Hint: target capacity = (sum + array sum) / 2 based on 2 splitted halfs of the array: one positive, another negative.
Bounded Problems (each item in the list can be used unlimited times):