Get Minimum Cores
Learn this problemProblem statement
Process scheduling algorithms are used by a CPU to optimally schedule the running processes. A core can execute one process at a time, but a CPU may have multiple cores.
There are n processes where the ith process starts its execution at start[i] and ends at end[i], both inclusive. Find the minimum number of cores required to execute the processes.
Function
getMinCores(start: int[], end: int[]) → int
Complete the function getMinCores in the editor below.
getMinCores takes the following arguments:
int start[n]: the start times of processesint end[n]: the end times of processes
Returns
int: the minimum number of cores required
Examples
Example 1
start = [1, 3, 4]end = [3, 5, 6]return = 2If the CPU has only one core, the first process starts at 1 and ends at 3. The second process starts at 3. Since both processes need a processor at 3, they overlap. There must be more than 1 core.
If the CPU has two cores, the first process runs on the first core from 1 to 3, the second runs on the second core from 3 to 5, and the third process runs on the first core from 4 to 6.
Return 2, the minimum number of cores required.
Constraints
1 ≤ n ≤ 10^51 ≤ start[i] ≤ end[i] ≤ 10^9
More IBM problems
- Parent Process NumberOA · Seen Jul 2026
- Request Retry CountOA · Seen Jul 2026
- Count Strictly Increasing Subsequences of Length 3OA · Seen Jul 2026
- Maximum Requests in a Time WindowOA · Seen Jul 2026
- Query Type Frequency WindowOA · Seen Jul 2026
- Minimum Number of Non-Empty Disjoint SegmentsOA · Seen Jul 2026
- Spam Text ClassificationOA · Seen Jul 2026
- Count Ideal NumbersOA · Seen Jun 2026