Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit98092ee

Browse files
committed
Code style fixes.
1 parent8c206a9 commit98092ee

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

‎src/algorithms/sets/knapsack-problem/Knapsack.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,16 @@ export default class Knapsack {
166166
constmaxPossibleItemsCount=Math.floor(availableWeight/currentItem.weight);
167167

168168
if(maxPossibleItemsCount>currentItem.itemsInStock){
169+
// If we have more items in stock then it is allowed to add
170+
// let's add the maximum allowed number of them.
169171
currentItem.quantity=currentItem.itemsInStock;
170-
this.selectedItems.push(currentItem);
171172
}elseif(maxPossibleItemsCount){
173+
// In case if we don't have specified number of items in stock
174+
// let's add only items we have in stock.
172175
currentItem.quantity=maxPossibleItemsCount;
173-
this.selectedItems.push(currentItem);
174176
}
177+
178+
this.selectedItems.push(currentItem);
175179
}
176180
}
177181
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp