Company: JPMorgan Chase
Difficulty: medium
Minimum Cores for Processes Problem Description An operating system's scheduler decides how running processes get assigned to available CPU cores, where each core can only handle one process at any given moment, even though a CPU may have several cores. You're given n processes, where process i begins at start[i] and finishes at end[i] (both endpoints included). Find the fewest cores that suffice to run every process. Complete the function getMinCores in the editor with the following arguments: int start[n] : the start times of processes int end[n] : the end times of processes Returns: int : the minimum number of cores required Examples Example 1: Input: n = 3 start = [1, 3, 4] end = [3, 5, 6] Output: 2 Explanation: With just a single core, process one runs from 1 to 3, and process two starts right at 3 - both need the processor at time 3, so they clash. A single core cannot do the job. With two cores, process one runs on the first core from 1 to 3, process two runs on the second core