FastPrepMinimum Memory for Hard Drives
Problems/Minimum Memory for Hard Drives

Minimum Memory for Hard Drives

Amazon logoAmazon● MediumNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

You are distributing games to N children. There are m games in total, and games[i] is the memory size of game i. You prepare N hard drives of the same size and give one to each child. Every child must receive at least one game, and all games must be distributed.

The games are handed out in the given order: each child receives one consecutive group of games, and each hard drive must hold the total size of its child's games.

Find the minimum memory capacity that each of the N hard drives needs so that the games can be distributed this way.

Function

minimumMemory(games: int[], N: int) → int

Complete the function minimumMemory in the editor.

minimumMemory has the following parameters:

  1. int[] games: the memory size of each game
  2. int N: the number of children (and hard drives)

Returns int: the minimum memory capacity of each hard drive

Examples

Example 1

games = [6, 7, 10, 12, 1]N = 3return = 13

Split the games, in order, into the groups [6, 7], [10] and [12, 1]. Their sums are 13, 10 and 13, so the largest is 13 and each hard drive needs 13 memory.

A capacity of 12 is not enough. The 12 cannot share a drive with its neighbour 10 (sum 22) or with 1 (sum 13), so the 12 needs its own drive and the 1 needs its own drive. One drive is left for 6 + 7 + 10 = 23, which is more than 12. So the answer is 13.

Constraints

  • 1 <= N <= m <= 10^5, where m is the length of games
  • 1 <= games[i] <= 10^4

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

  • Capacity to Ship Packages Within DaysMicrosoft · OA · ONSITE INTERVIEWMicrosoft interview questions
  • Rock JumpingIMC Trading · OAIMC Trading interview questions
  • Minimize Maximum Group DifferenceDRW · OADRW interview questions
  • Array NullificationQRT · OA
  • Minimum-Cost Solar Rooftop AllocationDeloitte · OADeloitte interview questions
  • Three-Part Partition with Minimum Largest RangeLSEG · OALSEG interview questions
  • K-Means ClusteringAtlassian · OAAtlassian interview questions
  • Get Minimum Development TimeSalesforce · OASalesforce interview questions
  • Job ExecutionMathWorks · OAMathWorks interview questions
  • Police Station 🚓The D.E. Shaw Group · OAThe D.E. Shaw Group interview questions

Interview reports that mention this question

  • Amazon New Grad OA Problems: Every Task We Have (Part 3 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, Earlier Reports (Part 5 of 5)
  • Amazon Full-Time OA Problems, Recent Reports (Part 4 of 5)
See Amazon hiring insights
Saved
class Solution {
    public int minimumMemory(int[] games, int N) {
      // write your code here
    }

}
Checking account…