FastPrepMinimum Storage Capacity
Problems/Minimum Storage Capacity

Minimum Storage Capacity

Amazon logoAmazon● MediumOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

In the Amazon Gaming Distribution System, a coordinator must share n computer games among k children. Game sizes are given in gameSize.

You order k pen drives, one for each child. All drives have the same storage capacity. Each child gets at least 1 game and at most 2 games. Every game must go to some child.

A child's games go on that child's pen drive. A drive can hold games only if their sizes add up to at most its capacity.

Return the smallest capacity that lets you give out all the games.

For example, let gameSize = [5, 3, 4] and k = 2. One child gets two games. Give 5 to one child and 3 and 4 to the other, which needs 3 + 4 = 7. Pairing 5 with 3 needs 8, and pairing 5 with 4 needs 9. The answer is 7.

Function

minimumStorageCapacity(gameSize: int[], k: int) → int

Complete the function minimumStorageCapacity in the editor.

minimumStorageCapacity has the following parameters:

  • int gameSize[n]: the size of each game
  • int k: the number of children

Returns int: the smallest pen drive capacity

Examples

Example 1

gameSize = [9, 2, 4, 6]k = 3return = 9

There are 4 games and 3 children, so one child gets two games. Every drive must hold the game of size 9, so the capacity is at least 9. Give the game of size 9 to the first child. Give the games of size 2 and 4 to the second child, which needs 2 + 4 = 6. Give the game of size 6 to the third child. No drive needs more than 9. The answer is 9.

Constraints

  • 1 <= n <= 10^5, where n is the length of gameSize
  • 1 <= k <= n <= 2 * k
  • 1 <= gameSize[i] <= 10^9

More Amazon interview questions

  • LRU Cache for Query ResultsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Maximal SquareONSITE INTERVIEW · Seen Nov 2026
  • Serialize and Deserialize a Binary TreeONSITE INTERVIEW · Seen Nov 2026
  • Course SchedulePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Course Schedule IIPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Diagonal Traversal of a Binary TreeONSITE INTERVIEW · Seen Nov 2026
  • Minimum Time to Spread Through a GridPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Consistent-Hash Packet RouterPHONE SCREEN · Seen Nov 2026
  • Count Connected ComponentsPHONE SCREEN · Seen Nov 2026
  • Maximize K-Element AND with an Increment BudgetOA · Seen Nov 2026

Similar questions at other companies

  • Maximum Easy Tasks After RearrangingIBM · OAIBM interview questions
  • Capacity to Ship Packages Within DaysMicrosoft · OA · ONSITE INTERVIEWMicrosoft interview questions
  • Latest Arrival to Catch a BusAutodesk · OAAutodesk interview questions
  • Minimum Last-Element RelocationsChubb · OAChubb interview questions
  • Generating Login CodesSnowflake · OASnowflake interview questions
  • Minimum Removals to Balance ArraySalesforce · OASalesforce interview questions
  • Minimum Adjacent Merges to Form a PalindromeArista Networks · OAArista Networks interview questions
  • Rock JumpingIMC Trading · OAIMC Trading interview questions
  • Minimize Maximum Group DifferenceDRW · OADRW interview questions
  • Array NullificationQRT · OA

Interview reports that mention this question

  • Amazon Full-Time OA Problems, Earlier Reports (Part 5 of 5)

Amazon interview experiences

  • Amazon Experienced SDE Onsite Questions: 1 Experience
  • Amazon SDE Onsite Interview Questions: 9 Experiences
  • Amazon SDE II and L5 FDE Interview Questions: 4 Experiences
  • Amazon Full-Time OA Problems, Recent Reports (Part 4 of 5)
  • Amazon New Grad OA Problems: Every Task We Have (Part 3 of 5)
See Amazon hiring insights
Saved
class Solution {
    public int minimumStorageCapacity(int[] gameSize, int k) {
      // write your code here
    }

}
Checking account…