FastPrepMaximum Concurrent Processes
Problem · Intervals

Maximum Concurrent Processes

Learn this problem
MediumMorgan Stanley logoMorgan StanleyINTERNOA

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

Examples

Example 1

processLogs = [[1,3],[2,4],[3,6]]return = 3

At 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 = 2

At 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 processLogs contains exactly two integers: [startTime, endTime].
  • For every process log, startTime <= endTime.
  • Both endpoints are inclusive.

More Morgan Stanley problems

drafts saved locally
public int maximumConcurrentProcesses(int[][] processLogs) {
  // write your code here
}
processLogs[[1,3],[2,4],[3,6]]
expected3
checking account