#### Category : dynamic-programming

So I made a program that takes in three strings, A, B, and C and determines whether or not C is a merge of A and B. A merge is defined as combination of the letters in A and B such that the ordering of the letters of A and B in relation to one ..

Example: I have two 10 foot boards. I want to saw those boards into pieces of 6", 5", 4", 3" and 2". So I use my first board to saw a 5" piece and a 4" piece. I use my second board to get 6" and 3" coins. I end up with two 1" scraps ..

I am getting a runtime error in some test cases when I try to submit my code. Problem Link: https://atcoder.jp/contests/dp/tasks/dp_a My code: #include<bits/stdc++.h> using namespace std; #define int long long int minCost(int n, vector<int> h, vector<int> dp) { if (dp[n] != -1) { return dp[n]; } if (n == 1) { return dp[n] = 0; ..

Given two random substrings (not necessarily same length) with only English letters, find the best common approximate substrings using dynamic programming. Each letter has a weight w of given value (i.e. set A with weight 1, B with 2, or all letters to 1), and penalty p of a random value. The best "common approximate ..

I need permutate some integers but without repeating and with condition so for example i have 4 place where i can put integers for every place i have array of integers which can be placed there so i need to know how many ways i can permutate it itegers for permutation : 8,6,1 – 1 ..

I am trying to implement a bottom up approach function to the rod cutting problem and I need to use this particular pseudo-code from the CLRS textbook. In it there two functions and one calls the other in this fashion (r,s) = EXTENDED-BOTTOM-UP-CUT-ROD(p,n) Where r and s are two different arrays. The function also returns ..

I need to deliver due tomorrow a coding problem to my university and it goes like this: Given an array of numbers, divide the array into K subarray such that it maximizes the product. Example: Input: 3 3 2 1 Output: {3, 3}, {2, 1} I am asked to use dynamic programming (tabulation), can I ..