FastPrepProcess Execution Time
Problems/Process Execution Time

Process Execution Time

IBM logoIBM● EasyFULLTIMENEW GRADOA
QuestionFunctionExamplesConstraints

Problem 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[]) → int

Examples

Example 1

start = [1, 2, 8]end = [5, 6, 10]return = 9

The 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^5
  • 1 <= start[i] <= end[i] <= 10^9

More IBM problems

  • Count Strictly Increasing Contiguous WindowsOA · Seen Nov 2026
  • Total Each Letter's Count in an Encoded StringOA · Seen Nov 2026
  • Count Servers With No Requests in a Time WindowOA · Seen Nov 2026
All IBM interview questionsSee IBM hiring insights
Saved
class Solution {
    public int getExecutionTime(int[] start, int[] end) {
      // write your code here
    }

}
Checking account…