Finish Time of Fixed-Length CPU Tasks
Problem statement
A machine has maxCpus identical CPUs. You are given an integer array startTimes, where startTimes[i] is the scheduled start time of task i. Every task takes exactly executionTime time units on one CPU. The array is not necessarily sorted and may contain equal values.
Run all tasks under these rules:
The problem statement continues
ProExamples
Example 1
startTimes = [1,4,6]executionTime = 5maxCpus = 2return = 11- Task at
1runs on CPU A from1to6. - Task at
4runs on CPU B from4to9. - At time
6, CPU A becomes free just as the third task is scheduled, so it runs from6to11.
The last task finishes at 11.
FastPrep Pro
Reported in 1 Google interview this weekUnlock this recently reported problem
FastPrep Pro gives you full access to interview problems reported within the last week.
- Full problem statement and constraints
- 2 more worked examples, explained
- Guided hints and editorial
- Run your code on real test cases
$8.25/month
$99 billed yearly — or $19 month-to-month. Cancel anytime.
Free plan — 2 of 2 free unlocks used this week