Code Question 1 Amazon ships millions of parcels to customers across the globe every day. 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[7. 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. Example Consider the number of types of products is
n=2
, the quantity of each product type is quantity
=[2,4]
, the truck capacity is capacity
=3
, and the maximum allowed quantity of a product type is max_parcels_of_same_type
=2
.
?
?
A truck cannot carry 3 parcels of type 2 since only max_parcels_of_same_type
=2
of any one type can be on a truck. All parcels can be shipped in 2 trucks without violating any constraints. The answer is 2. Function Description Complete the function calculateMinTrucks in the editor below. 1 > import java.io.*; .. class Result { 11 12 1* 13 * Complete the 'calculateMinTrucks' function below. 14 * 15 * The function is expected to return a LONG_INTEGER. 16 * The function accepts following parameters: 17 * 1. INTEGER_ARRAY quantity 18 * 2. INTEGER num 19 * 3. INTEGER k
20,**(*)/()
21 22 22 23 23 Code Question 1 Amazon ships millions of parcels to customers across the globe every day. 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[7. 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. Example Consider the number of types of products is
n=2
, the quantity of each product type is quantity
=[2,4]
, the truck capacity is capacity
=3
, and the maximum allowed quantity of a product type is max_parcels_of_same_type
=2
.
?
?
A truck cannot carry 3 parcels of type 2 since only max_parcels_of_same_type
=2
of any one type can be on a truck. All parcels can be shipped in 2 trucks without violating any constraints. The answer is 2. Function Description Complete the function calculateMinTrucks in the editor below. 1 > import java.io.*; .. class Result { 11 12 1* 13 * Complete the 'calculateMinTrucks' function below. 14 * 15 * The function is expected to return a LONG_INTEGER. 16 * The function accepts following parameters: 17 * 1. INTEGER_ARRAY quantity 18 * 2. INTEGER num 19 * 3. INTEGER k
20,**(*)/()
21 22 22 23 23