#415 Maximum Truck Underload
A truck loading station needs an algorithm for distributing cargo among trucks. Load the cargo onto the trucks and then return the maximum amount of unused capacity:
private int calcTrucks(int[] weights, int trucksCount, int truckMaxCapacity) {
...
}
Parameters:
-
weights— array of cargo weights; -
trucksCount— number of trucks; -
truckMaxCapacity— maximum truck capacity.
Examples:
Input - [10, 100, 20, 30, 40, 10], 4, 100
Output - 90
Input - [10, 100, 20, 30, 40], 4, 100
Output - 0
Question review
Sign in to start the dialogue
The mentor keeps the context of the current question and your previous messages.
Sign in
Available with Premium
This is just one of the solutions available with Premium. And more:
- 250+ advanced lectures
- 1300+ practice exercises
- 500+ solutions to problems from real interviews
- Personalized Java Hub certificates
- Expanded access to the AI mentor