Skip to content

Commit 361b410

Browse files
authored
Use explicit cast to int in FractionalKnapsack (TheAlgorithms#4971)
1 parent 3392b51 commit 361b410

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/main/java/com/thealgorithms/greedyalgorithms/FractionalKnapsack.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public static int fractionalKnapsack(int weight[], int value[], int capacity) {
3232
current -= weight[index];
3333
} else {
3434
// If only a fraction of the item can fit, add a proportionate value.
35-
finalValue += ratio[i][1] * current;
35+
finalValue += (int) (ratio[i][1] * current);
3636
break; // Stop adding items to the knapsack since it's full.
3737
}
3838
}

0 commit comments

Comments
 (0)