Peak Task Concurrency Intervals
Problem statement
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.
Unlock this recently reported problem
FastPrep Pro gives you full access to interview problems reported within the last week.
- Full problem statement and constraints
- 2 more worked examples, explained
- Guided hints and editorial
- Run your code on real test cases
$99 billed yearly — or $19 month-to-month. Cancel anytime.