Peak Task Concurrency Intervals
Reported by candidates from Google's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Google's October 2026 OA reports include a task concurrency problem where brute force dies the moment the time values get large. You can't walk every time unit and count active tasks, and you can't compare every pair of intervals either. The real move is to treat each task as two events, a start and an end, and sweep through them in order. It looks like an overlap-counting question, but the output format is where people lose points. If you blank on the merge step, StealthCoder is the invisible hedge running during the live assessment.
The problem
Each row [start, end] in tasks represents one task active during the half-open interval [start, end). A task ending at time t is not concurrent with a task starting at time t, and a zero-length task contributes no active time. Find the greatest number of tasks active at once. Return every maximal nonempty time interval that attains this peak, in chronological order. Represent each result as [start, end, peakCount]. Merge adjacent peak segments when the active count remains equal to the peak across their shared boundary. Examples Example 1 tasks = [[1,4],[2,6],[4,5],[7,9],[7,9]] return = [[2,5,2],[7,9,2]] Two tasks are active continuously from time 2 through 5; the end at 4 and start at 4 do not create a gap in the count. Two other tasks overlap from 7 through 9.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The trick is a sweep line. Turn each [start, end) into +1 at start and -1 at end, and skip zero-length tasks entirely. Sort events by time, then group all events sharing a timestamp and apply them together. That grouping handles the half-open rule: an end at 4 and a start at 4 net out before you read the count. Track the max count across segments, then collect segments where the count equals the max. The pitfall is the merge. Because you process whole timestamps, a peak segment that continues across a boundary where the count stays at the peak must extend the previous result, not start a new one. Compare the last result's end to the new segment's start and merge when they touch. Pitfall two is applying events one at a time and reading a false dip. If you freeze on the grouping logic, StealthCoder can surface a working solution while you're in the live OA.
If you see this problem in your OA tomorrow, the play is to recognize the pattern in 30 seconds. StealthCoder buys you that recognition.
You can drill Peak Task Concurrency Intervals cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Google's OA.
Google reuses patterns across OAs. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Peak Task Concurrency Intervals FAQ
What's the trick for the Google peak task concurrency problem?+
Use a sweep line. Convert each task into a +1 event at start and a -1 event at end, sort by time, and apply all events at the same timestamp before reading the count. That handles the half-open interval rule cleanly and runs in O(n log n).
Why does brute force fail here?+
Checking every time unit depends on the size of the time range, which can be huge. Checking every pair of tasks is quadratic. Sorting 2n events and scanning once depends only on the number of tasks, so it scales.
How do I handle a task ending exactly when another starts?+
Process every event at the same timestamp together before recording the count. Since intervals are [start, end), the end at t removes the task and the start at t adds one, so the net count at t reflects only truly concurrent tasks. Don't read the count between those two events.
How do I merge adjacent peak segments?+
After computing each segment with a count equal to the max, check the last result. If its end equals the new segment's start and both have the peak count, extend the last end instead of appending. You need the max first, so either do two passes or fix up results when a higher peak appears.
How should I prepare in 48 hours for this OA?+
Write the sweep line from scratch twice, once with event sorting and once with a map of time to delta. Then test edge cases: zero-length tasks, duplicate tasks, touching intervals, and a single task. Those cases are where candidates usually lose points on this kind of problem.