Get Minimum Pen Drive Size
Learn this problemProblem statement
Within the Amazon Gaming Distribution System, a logistics coordinator is faced with the task of efficiently distributing n games among k different children. Each game is characterized by its size, denoted by gameSize[i] for 1 ≤ i ≤ n.
To facilitate the distribution process, the coordinator opts to utilize pen drives, ordering k pen drives with identical storage capacity. Each pen drive can receive a maximum of 2 games, and every child must receive at least one game, also no game should be left unassigned.
Considering the impracticality of transferring large game files over the internet, the strategy involves determining the minimum storage capacity required for the pen drives. A pen drive can only store games if the sum of their sizes does not exceed the pen drive's storage capacity.
What is the minimum storage capacity of pen drives that you must order to be able to give these games to the children?
Function
getMinSize(gameSize: int[], k: int) → int
Complete the function getMinSize in the editor.
getMinSize has the following parameters:
int gameSize[n]: the size of each gameint k: the number of children amongst whom the games are to be distributed
Returns
int: an integer variable denoting the minimum capacity of pen drives required to distribute the games amongst the children
Examples
Example 1
gameSize = [9, 2, 4, 6]k = 3return = 9Constraints
1 ≤ k ≤ n ≤ 2 * 10^51 ≤ gameSize[i] ≤ 10^9n ≤ 2*k
More Amazon problems
- Secure Maximum DeliveriesOA · Seen Jul 2026
- Find Median from Data StreamONSITE INTERVIEW · Seen Jul 2026
- Handwritten SigmoidPHONE SCREEN · Seen Jul 2026
- Handwritten SoftmaxPHONE SCREEN · Seen Jul 2026
- Koko Eating BananasONSITE INTERVIEW · Seen Jul 2026
- Loyal Customers Across Two DaysONSITE INTERVIEW · Seen Jul 2026
- Maximum System Memory CapacityOA · Seen Jul 2026
- Package Delivery SystemOA · Seen Jul 2026