Minimum Cores to Handle Processes
CPU scheduling algorithms are used to efficiently manage the execution of processes. A core can handle one process at a time, but CPUs often have multiple cores.
Given n processes, where the i-th process starts at start[i] and finishes at end[i], both inclusive, determine the minimum number of cores needed to handle all processes.
Complete the function getMinCores in the editor with the following arguments:
int start[n]: the start times of the processesint end[n]: the finish times of the processes
start = [1, 3, 4] end = [3, 5, 6] return = 2
If 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.
public int getMinCores(int[] start, int[] end) {
// write your code here
}