Skip to main content
0 votes
0 answers
74 views

Problem Statement There are N items, numbered 1, 2, …, N. For each item i (1 ≤ i ≤ N): It has a weight w[i] It has a value v[i] Taro wants to choose some of these N items and carry them home in a ...
0 votes
0 answers
55 views

How can the following recursion + memoization code be converted into a tabulation format dynamic programming solution? The code is working but I want to improve it. The challenge I am facing is ...
3 votes
0 answers
58 views

A graph G(V,E) is defined by a set of vertices V and a set of edges E. Given W⊆V, find a connected subgraph G'(V',E') of G that satisfies the following conditions: i) ∀p∈V,∃p'∈V' such that p′ is ...
0 votes
0 answers
59 views

Problem: Given elements and sets that the elements can corespond to, find optimal division these elements to sets, such that number of sets is minimal. Example: 'a' : (1, 2), 'b' : (1, 3), 'c' : (3, 5)...
1 vote
0 answers
47 views

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, even ...
1 vote
0 answers
145 views

I have two strings, s1 and s2, and I need to find the length of the longest substring that appears in both strings. The substring must be contiguous in both s1 and s2. For example: If s1 = "...
0 votes
0 answers
76 views

Given an array of arrays, with each sub-array contains unique elements, but among different sub-arrays, there might be the same element. Select the top K sub-arrays, that the union of all elements ...
0 votes
0 answers
245 views

I try to implement ZigZag Indicator in TypeScript. My ZigZagCalculation function accepts as a parameters: Bar[] bar, deviation: number And returns array with all the zig-zag points. My bar array has a ...
0 votes
0 answers
19 views

I'm working on a dynamic programming problem related to counting the number of ways to partition an array into two subsets such that the absolute difference between their sums is equal to a given ...
0 votes
0 answers
258 views

Suppose we have a shop and sell 5 different products: A, B, C, D and E. Each product has a fixed base cost of $8.00. Now we represent the amount of each product bought as a tuple (a, b, c, d, e). ...
3 votes
0 answers
66 views

While solving fabonocci problem using recursion and memoization in JavaScript, I got "Maximum Call Stack Exceeded" error when I try to run it with large inputs. To troubleshoot, I copied the ...
0 votes
0 answers
51 views

On a binary matrix M, a cyclic island is a region of 1s where the region encircles itself (horizontal, vertical and cross directions are allowed) Given a matrix M, Allowing neighbors to be in any of ...
2 votes
0 answers
66 views

I'm trying to understand why first one fails and second works, all I'm doing is passing along coinTrack, call it redundant but why does it not work? It works without memoization, but on using ...
1 vote
0 answers
56 views

I have the following task, but I don’t understand how I could solve it through dynamic programming or perhaps I need to solve it through graphs, could someone help me solve it? The frog Sandy likes ...
0 votes
0 answers
164 views

I am working on a project to optimize SQL queries by determining the optimal join order using dynamic programming in Python. Context I am connecting to a PostgreSQL database and need to calculate the ...

15 30 50 per page
1
2 3 4 5
46