Skip to content

Commit 2483c1c

Browse files
authoredJun 5, 2021
fix knapsack.js findValues
1 parent c4ea585 commit 2483c1c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed
 

‎src/js/algorithms/dynamic-programing/knapsack.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function findValues(n, capacity, kS) {
1+
function findValues(n, capacity, kS, weights, values) {
22
let i = n;
33
let k = capacity;
44
// console.log('Items that are part of the solution:');
@@ -7,8 +7,8 @@ function findValues(n, capacity, kS) {
77
// console.log(
88
// item ' + i + ' can be part of solution w,v: ' + weights[i - 1] + ',' + values[i - 1]
99
// );
10+
k -= weights[i-1]
1011
i--;
11-
k -= kS[i][k];
1212
} else {
1313
i--;
1414
}

0 commit comments

Comments
 (0)