Problem · Intervals
Maximum Concurrent Processes
Learn this problemProblem statement
You are given n process logs. Each log is an inclusive integer interval [startTime, endTime], meaning that the process runs at every minute from startTime through endTime.
Return the maximum number of processes that are running simultaneously at any integer minute.
Function
maximumConcurrentProcesses(processLogs: int[][]) → intExamples
Example 1
processLogs = [[1,3],[2,4],[3,6]]return = 3At minute 3, all three inclusive intervals contain that minute, so three processes are running simultaneously.
Example 2
processLogs = [[2,6],[1,2],[3,5]]return = 2At minute 2, the first two processes overlap. At minutes 3 through 5, the first and third processes overlap. No minute belongs to all three intervals.
Constraints
- Each entry in
processLogscontains exactly two integers:[startTime, endTime]. - For every process log,
startTime <= endTime. - Both endpoints are inclusive.