Problem · Intervals
Process Execution Time
Learn this problemProblem statement
You are given the inclusive start and end times of multiple processes. Compute the total amount of time during which at least one process is running.
Intervals are inclusive, so a process running from 1 to 5 contributes 5 - 1 + 1 = 5 units of time. Overlapping intervals should be merged before summing their lengths.
Return the total covered time.
Function
getExecutionTime(start: int[], end: int[]) → intExamples
Example 1
start = [1, 2, 8]end = [5, 6, 10]return = 9The first two processes merge into [1, 6] for 6 units. The third process contributes 3 more units from [8, 10]. Total = 9.
Constraints
1 <= n <= 2 * 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