FastPrepPeak Task Concurrency Intervals

Peak Task Concurrency Intervals

Google logoGoogle● MediumINTERNONSITE INTERVIEW

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.

The problem statement continues
Pro

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.

FastPrep Pro
Reported in 1 Google interview this week

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
$8.25/month

$99 billed yearly — or $19 month-to-month. Cancel anytime.

Free plan — 2 of 2 free unlocks used this week
See Google hiring insights
CodePython 3
Run and Submit unlock with Pro
FastPrep Pro
Reported in 1 Google interview this week

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
$8.25/month

$99 billed yearly — or $19 month-to-month. Cancel anytime.

Free plan — 2 of 2 free unlocks used this week