Description
Solutions
Get Min Machines
📚RELATED PROBLEMS
Implement a prototype service for resource estimation.
Given a set of n
tasks, the ith (0 <= i < n)
task runs from time start[i]
through end[i]
.
Implement a task scheduler method that finds the minimum number of
machines required to complete the tasks. A task can be scheduled on exactly
on machine, and one machine can run only one task at a time.
Function Description
Complete the function getMinMachines
in the editor.
getMinMachines
has the following parameters:
int[n]start
: the start times of tasksint[n]end
: the end times of tasksReturns
int
: the minimum number of machines required to run all the tasks.
Example 1:
Input: start = [1, 8, 3, 9, 6], end = [7, 9, 6, 14, 7]
Output: 3
Explanation:Consider the following task schedule. Times in parentheses are the inclusive start and end times for each job. 1. Machine 1: [(1, 7), (8, 9)] 2. Machine 2: [(3, 6), (9, 14)] 3. Machine 3: [(6, 7)] Hence, the number of machines required is 3.
Constraints:
1 <= n <= 2 * 105
1 <= start[i] <= end[i] <= 109
Related Problems
Testcase
Result
Case 1
input:
output: