Use explicit cast to int in FractionalKnapsack (#4971)

This commit is contained in:
Piotr Idzik
2023-11-29 22:21:25 +01:00
committed by GitHub
parent 3392b5116d
commit 361b4108ee

View File

@ -32,7 +32,7 @@ public class FractionalKnapsack {
current -= weight[index];
} else {
// If only a fraction of the item can fit, add a proportionate value.
finalValue += ratio[i][1] * current;
finalValue += (int) (ratio[i][1] * current);
break; // Stop adding items to the knapsack since it's full.
}
}