Questions tagged [dynamic-programming]
Dynamic programming is an algorithmic technique for efficiently solving problems which have recursive structure with many overlapping subproblems. Do NOT use this tag for general "dynamic" behavior in code.
dynamic-programming
5,695
questions
1
vote
1
answer
70
views
Rod cutting problem: alternate recurrence in interview
The rod cutting problem is described in section 15.1 of the book "Introduction to algorithms" by Carmen et.al. We are given an array, p where p[j] represents the money we'll get for a rod of ...
3
votes
3
answers
159
views
Longest Repeating Subsequence: Edge Cases
Problem
While solving the Longest Repeating Subsequence problem using bottom-up dynamic programming, I started running into an edge case whenever a letter was repeated an odd number of times.
The goal ...
0
votes
1
answer
64
views
Finding the most optimal way for updating a dynamic-programming array
Imagine there are n people in a line, which every one of them has there unique value for themselves from 1 to n, we try to sort them like this:
repeat
swapped = false
for i from 1 to n do:
...
0
votes
1
answer
150
views
how to make column readonly based on the value of another column in oracle apex
I have created editable interactive grid in oracle apex based on employees table. In IG i have mutiple column such as ename,salary and comm. I want to make the comm column readonly based on the value ...
0
votes
1
answer
103
views
Best way to crate a simple blog website using using Next.js (MDX or Data fetching)?
I want to create a blog website to write life and code blog, with the rsc and supported meta content like ranking with the google and apple bot with dynamic OG image.
next.js is the framework provides ...
0
votes
2
answers
68
views
why ArrayIndexOutOfBoundsException is occurring?
def change(amount: Int, coins: Array[Int]): Int = {
val dp = Array[Int](amount + 1)
dp(0) = 1
for {
coin <- coins
i <- coin to amount
} dp(...
2
votes
3
answers
207
views
Maximum Sum Without Skipping Two Contiguous Elements
The task is to find the maximum sum of a subsequence of integers from a given list. The subsequence must follow two conditions:
It must be contiguous, meaning the selected elements are in consecutive ...
0
votes
2
answers
55
views
dynamic programming: (minimum days of not eating icecreams)
Minimum Days Not Eating Ice-cream
Ram decides to eat ice-cream for N days. On each day the ice-cream shop can have chocolate flavour or mango flavour or both or none. The availability of ice-cream ...
1
vote
1
answer
133
views
Check if a string has a palindrome subsequence of length k
The string S consists of lowercase English letters. I want to know whether this string contains a palindrome subsequence of length exactly k or not. I want a dynamic programming algorithm that runs ...
0
votes
0
answers
72
views
How to efficiently compute similarity scores for prefixes of a string with another string in C?
I'm working on a problem involving string matching where I need to compute the similarity scores for each prefix of a string C against another string S. The similarity score for a prefix P of C and S ...
0
votes
0
answers
10
views
How do i print only substrings and not subsequences , current solution prints all subsequence as well?
This is a solution for printing the longest Palindormic substring , here it is printing all the subsequence.
s =
"aacabdkacaa"
Use Testcase
Output
"aacabacaa"
class Solution {
...
3
votes
1
answer
67
views
Find nonnegative integer weights of integer inputs array for integer output, minimizing sum of weights
Problem: Given an array of integers inputs and an integer output, return an array of non-negative integers weights such that the sum of the element-wise product of inputs and weights equals output and ...
0
votes
0
answers
19
views
dynamic programming min path grid sum
"I recently found a frustrating error in my code. I have two solutions for finding the minimum path sum using dynamic programming (DP). The first solution, which I wrote, doesn't seem to work, ...
2
votes
1
answer
89
views
How to measure performance metric in a dynamic programming algorithm
I am trying to use the Cell Updates Per Second (CUPS) metric to measure the performance of the sequence alignment algorithm. I saw the metric being used in several papers (ref1, ref2)but none of them ...
1
vote
1
answer
235
views
fusing inner lists within list function to return highest possible integer dynamic programming
new to programming and currently trying to challenge myself and learn dynamic programming. I have this question to implement a function that takes an array and outputs the 'highest cuteness' of the ...