π FastPrep match note: This version is based on a reported Amazon SDE2 full-time onsite Bar Raiser round prompt and should match the core task about 90-95%: given process running intervals, return the maximum number running at the same time.
The main uncertainty is whether the original wording explicitly counted endpoints as running; the reported example only reaches 3 if time 3 belongs to both [1, 3] and [3, 6], so we make the inclusive endpoint rule explicit and add a few practice examples and constraints for clarity.
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.
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?
intervals = [[1, 3], [2, 5], [3, 6]] return = 3
At time 3, all three processes are running. Since intervals are inclusive, both [1, 3] and [3, 6] include time 3.
intervals = [[1, 2], [3, 4], [5, 6]] return = 1
No two processes overlap, so the maximum number of concurrent processes is 1.
intervals = [[1, 10], [2, 3], [4, 5], [6, 7]] return = 2
The long-running process overlaps with each shorter process, but the shorter processes do not overlap with one another.
intervals = [[1, 4], [2, 6], [4, 8], [6, 9]] return = 3
At time 4, [1, 4], [2, 6], and [4, 8] are all running because interval endpoints are inclusive.
1 <= intervals.length <= 1000000 <= start <= end <= 1000000000- All start and end values are integers.
- Intervals are inclusive:
[start, end].
- Closest Version DateONSITE INTERVIEW Β· Seen Jul 2026
- Maximum Product New RatingOA Β· Seen Jul 2026
- Permutation SorterOA Β· Seen Jul 2026
- Get Distinct Pairs (Also apply to AS intern)Seen Jul 2026
- Maximum Final ValueSeen Jul 2026
- Minimum Delivery Center InconvenienceOA Β· Seen Jun 2026
- Unfulfilled Customers by Inventory PriorityOA Β· Seen Jun 2026
- Minimum Operations to Make the Integer ZeroSeen Jun 2026
public int maxConcurrentProcesses(int[][] intervals) {
// write your code here
}