This problem is an adaptation of LeetCode's Meeting Rooms II. It is advisable to solve that problem first if you haven't already.
You are given two arrays start and end, each of length n, describing a set of jobs. The i-th job begins at time start[i] and finishes at end[i], and the interval is inclusive on both ends. A machine can process only one job at any given moment, and each job requires a dedicated machine for its entire execution.
Two jobs are said to conflict if they overlap at any time unit. Since intervals are closed, a job that ends at time t and a job that starts at time t are considered to have a conflict and cannot share the same machine.
Determine the smallest number of machines needed to execute all n jobs without any two jobs overlapping on the same machine.
Example 1:
Input: start = [1, 8, 3, 9, 6], end = [7, 9, 6, 14, 7]
Output: 3
Explanation: At time 6, three jobs are active simultaneously: [1,7], [3,6], and [6,7]. Because both endpoints are included, all three occupy time 6 at once, forcing a three-way conflict. Hence, at least 3 machines are required.
Example 2:
Input: start = [1, 2, 2], end = [2, 2, 3]
Output: 3
Example 3:
Input: start = [1, 5, 10], end = [3, 7, 12]
Output: 1
Constraints:
start.length == end.length == n0 ≤ start[i] ≤ end[i] ≤ 10^9