Maximum Concurrent Processes (Bar Raiser Round)
Updated
Problem statement
Both ends of an interval count, so two intervals that only touch, such as [1, 3] and [3, 6], overlap at time 3. The task is a variant of Meeting Rooms II and can be solved with a sweep line.
You are given a list of processes. Each process has a running interval represented as [start, end].
A process is considered running at every integer time from start through end, inclusive.
Return the maximum number of processes running at the same time.
Function
maxConcurrentProcesses(intervals: int[][]) → int Complete the function maxConcurrentProcesses in the editor.
maxConcurrentProcesses has the following parameter:
int intervals[n][2]: each interval is[start, end], wherestart <= end.
Returns int: the maximum number of processes running concurrently at any time.
Follow-up
How would your answer change if each interval were half-open, meaning [start, end), where the process stops running before end?
Examples
Example 1
intervals = [[1, 3], [2, 5], [3, 6]]return = 3At time 3, all three processes are running. Since intervals are inclusive, both [1, 3] and [3, 6] include time 3.
Example 2
intervals = [[1, 2], [3, 4], [5, 6]]return = 1No two processes overlap, so the maximum number of concurrent processes is 1.
Example 3
intervals = [[1, 10], [2, 3], [4, 5], [6, 7]]return = 2The long-running process overlaps with each shorter process, but the shorter processes do not overlap with one another.
Example 4
intervals = [[1, 4], [2, 6], [4, 8], [6, 9]]return = 3At time 4, [1, 4], [2, 6], and [4, 8] are all running because interval endpoints are inclusive.
Constraints
1 <= intervals.length <= 1000000 <= start <= end <= 1000000000- All start and end values are integers.
- Intervals are inclusive:
[start, end].
Source note: Author-written prompt excerpt retained for source fidelity.
More Amazon Onsite Interview questions
- LRU Cache for Query ResultsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Maximal SquareONSITE INTERVIEW · Seen Nov 2026
- Serialize and Deserialize a Binary TreeONSITE INTERVIEW · Seen Nov 2026
- Course SchedulePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Course Schedule IIPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Diagonal Traversal of a Binary TreeONSITE INTERVIEW · Seen Nov 2026
- Minimum Time to Spread Through a GridPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Optimal Account BalancingONSITE INTERVIEW · Seen Nov 2026
- Task SchedulerOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Number of IslandsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
Similar questions at other companies
- Merge Overlapping IntervalsAtlassian · PHONE SCREEN · ONSITE INTERVIEWAtlassian interview questions
- Peak Chat Load Across AgentsCresta · PHONE SCREENCresta interview questions
- Finish Time of Fixed-Length CPU TasksGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
- Meeting Scheduling SystemHevo Data · ONSITE INTERVIEW
- Meeting Rooms IIeBay · PHONE SCREENeBay interview questions
- Maximum Intervals Overlapping a Fixed-Length WindowBooking.com · ONSITE INTERVIEW
- Minimum Rooms for Meeting IntervalsOYO Rooms · PHONE SCREEN
- Meeting Rooms IIByteDance · PHONE SCREENByteDance interview questions
- Majority Labels over Audio IntervalsNooks · PHONE SCREEN
- Meeting Rooms IISalesforce · ONSITE INTERVIEWSalesforce interview questions