Skip to content

Commit b7b7107

Browse files
🎨 style(integerKnapsack): Use better variable names.
1 parent fee7b25 commit b7b7107

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/integerKnapsack.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ const integerKnapsack = (v, w, n, W, m = new v.constructor(W + 1).fill(0)) => {
66
assert(Number.isInteger(W) && W >= 0);
77
assert(m.length >= W + 1);
88
for (let i = 0; i < n; ++i) {
9-
const x = w[i];
10-
const y = v[i];
11-
assert(Number.isInteger(x) && x >= 0 && x <= W);
12-
const s = W - x;
9+
const wi = w[i];
10+
const vi = v[i];
11+
assert(Number.isInteger(wi) && wi >= 0 && wi <= W);
12+
const s = W - wi;
1313
for (let j = 0; j <= s; ++j) {
14-
m[j] = Math.max(m[j], m[j + x] + y);
14+
m[j] = Math.max(m[j], m[j + wi] + vi);
1515
}
1616
}
1717

0 commit comments

Comments
 (0)