FastPrepMinimum CPUs for Fixed-Duration Jobs
Problems/Minimum CPUs for Fixed-Duration Jobs

Minimum CPUs for Fixed-Duration Jobs

Google logoGoogle● MediumINTERNNEW GRADPHONE SCREENONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The firsthand Google Software Engineer internship report gives n job start times and one shared job duration S, and asks for the minimum number of CPUs. Its public answer confirms a priority queue and the maximum heap size. The report did not say whether a CPU can be reused at the exact end time, or give the input limits. Our version is about 97% the same as the reported question.

You are given an array startTimes, where each value is the start time of one job, and a positive integer duration. Every job runs for exactly duration time units.

Each CPU can execute at most one job at a time. A CPU becomes available immediately when its current job ends, so a job ending at time t does not overlap a job starting at time t.

Return the minimum number of CPUs required to execute all jobs at their specified start times.

Function

minimumCpus(startTimes: int[], duration: int) → int

Examples

Example 1

startTimes = [0,1,2]duration = 2return = 2

The first two jobs overlap. At time 2, the job that started at 0 ends and its CPU can immediately run the third job, so two CPUs suffice.

Example 2

startTimes = [1,5,10]duration = 3return = 1

Each job ends before the next one starts, so one CPU can execute all three jobs.

Example 3

startTimes = [4,4,4]duration = 1return = 3

All three jobs start simultaneously, so each requires a different CPU.

Constraints

  • 1 <= startTimes.length <= 100000.
  • 0 <= startTimes[i] <= 1000000000.
  • 1 <= duration <= 1000000000.

More Google Onsite Interview questions

  • Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Distinct Subset SumsONSITE INTERVIEW · Seen Nov 2026
  • Playlist With No Same Artist in a RowONSITE INTERVIEW · Seen Nov 2026
  • Delete Nodes and Return Forest RootsONSITE INTERVIEW · Seen Nov 2026
  • Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • First and Last Target Position in a Mountain ArrayONSITE INTERVIEW · Seen Nov 2026
  • Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • 0/1 Knapsack with Weight and Volume LimitsONSITE INTERVIEW · Seen Nov 2026
  • Batched Subsequence Word MatchesONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Meeting Rooms IIeBay · PHONE SCREENeBay interview questions
  • Meeting Rooms IIByteDance · PHONE SCREENByteDance interview questions
  • Meeting Rooms IISalesforce · ONSITE INTERVIEWSalesforce interview questions
  • Generate Complete Inputs for a Supplied ClassifierGeneral Motors · ONSITE INTERVIEW
  • Meeting Rooms IIAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Maximum Number of Events That Can Be AttendedSnowflake · PHONE SCREENSnowflake interview questions
  • Minimum Workers with Job AssignmentsLyft · ONSITE INTERVIEWLyft interview questions
  • Meeting Rooms IIRoblox · PHONE SCREENRoblox interview questions
  • Merge K Sorted Interval ListsBloomberg LP · ONSITE INTERVIEWBloomberg LP interview questions
  • Fewest Rooms for All MeetingsAdobe · PHONE SCREENAdobe interview questions

Interview reports that mention this question

  • Google SWE Intern OA and Interviews: 42 Experiences (Part 1 of 3)

Google interview experiences

  • Google interviews · November 2026
  • Google Software Engineer Onsite Questions: 10 Experiences
  • Google OA: What It Tests (2026)
  • Google L4 SWE Phone Screen: 1 Experience
  • Google ML Engineering Manager Onsite: 1 Experience
All Google interview questionsSee Google hiring insights
Saved
class Solution {
    public int minimumCpus(int[] startTimes, int duration) {
        // Write your code here.
    }
}
Checking account…