Round 1
Questions: In a given center, n types of products are to be shipped where the number of parcels of product type 'i' is denoted by quantity[i]. A truck can carry a maximum 'capacity' number of parcels with no more than 'max_parcels_of_same_type' parcels of the same type. Find the minimum number of trucks needed to ship all parcels of all types from this center.
Input/Output Examples:
-
Input: n=2, quantity=[2,4], capacity=3, max_parcels_of_same_type=2
Output:
truck1 - 1 parcel of type 1 & 2 parcels of type 2
truck2 - 1 parcel of type 1 & 2 parcels of type 2
Minimum trucks - 2 -
Input: n=3, quantity=[4,4,3], capacity=3, max_parcels_of_same_type=3
Output: Minimum trucks - 4 -
Input: n=4, quantity=[3,2,2,6], capacity=2, max_parcels_of_same_type=1
Output: Minimum trucks - 7
Candidate's Approach
The candidate's approach was to calculate the total sum of parcels and return the result of (sum/Math.min(capacity, max_parcels_of_same_type)) + 1. However, this approach only passed 4 out of 15 test cases.
Interviewer's Feedback
No feedback provided.