We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bf34027 commit 4c137d8Copy full SHA for 4c137d8
src/integerKnapsack.js
@@ -7,6 +7,7 @@ const integerKnapsack = (v, w, n, W, m = new w.constructor(W + 1).fill(0)) => {
7
assert(m.length >= W + 1);
8
for (let i = 0; i < n; ++i) {
9
const x = w[i];
10
+ assert(Number.isInteger(x) && x >= 0 && x <= W);
11
const s = W - x;
12
for (let j = 0; j <= s; ++j) {
13
m[j] = Math.max(m[j], m[j + x] + v[i]);
0 commit comments