mirror of
https://github.com/TheAlgorithms/Java.git
synced 2026-02-04 12:50:12 +08:00
Use explicit cast to int in FractionalKnapsack (#4971)
This commit is contained in:
@@ -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.
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user