FastPrepPeak Task Concurrency Intervals
Problems/Peak Task Concurrency Intervals

Peak Task Concurrency Intervals

Google logoGoogle● MediumINTERNONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report asks for the peak number of tasks running at once, the time spans where that peak happens, and a sweep-line solution. It does not say how endpoints count or how to write the output. Our version is about 95% the same as the reported question.

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.

Return an empty matrix when no task has positive duration.

Function

peakTaskConcurrency(tasks: int[][]) → int[][]

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.

Example 2

tasks = [[1,5],[2,4],[3,6]]return = [[3,4,3]]

All three tasks are active only during [3,4), so the peak is 3.

Example 3

tasks = [[5,5],[8,8]]return = []

Both intervals have zero length, so no task is active over a nonempty span.

Constraints

  • 0 <= tasks.length <= 100000.
  • Each row contains exactly two integers [start, end].
  • -10^9 <= start <= end <= 10^9.
  • The returned intervals must be maximal and sorted by start time.

More Google Onsite Interview questions

  • Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Distinct Subset SumsONSITE INTERVIEW · Seen Nov 2026
  • Playlist With No Same Artist in a RowONSITE INTERVIEW · Seen Nov 2026
  • Delete Nodes and Return Forest RootsONSITE INTERVIEW · Seen Nov 2026
  • Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • First and Last Target Position in a Mountain ArrayONSITE INTERVIEW · Seen Nov 2026
  • Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • 0/1 Knapsack with Weight and Volume LimitsONSITE INTERVIEW · Seen Nov 2026
  • Batched Subsequence Word MatchesONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Meeting Scheduling SystemHevo Data · ONSITE INTERVIEW
  • Detect a Server RAM Capacity BreachMyntra · ONSITE INTERVIEWMyntra interview questions
  • Peak Chat Load Across AgentsCresta · PHONE SCREENCresta interview questions
  • Majority Labels over Audio IntervalsNooks · PHONE SCREEN
  • Brightest Position on a StreetCapital One · OACapital One interview questions
  • Merge IntervalsApple · OA · PHONE SCREEN · ONSITE INTERVIEWApple interview questions
  • Merge Overlapping IntervalsAtlassian · PHONE SCREEN · ONSITE INTERVIEWAtlassian interview questions
  • Maximum Concurrent Processes (Bar Raiser Round)Amazon · PHONE SCREEN · ONSITE INTERVIEW
  • Maximum Intervals Overlapping a Fixed-Length WindowBooking.com · ONSITE INTERVIEW
  • Meeting Rooms IISalesforce · ONSITE INTERVIEWSalesforce interview questions

Google interview experiences

  • Google interviews · November 2026
  • Google Software Engineer Onsite Questions: 10 Experiences
  • Google OA: What It Tests (2026)
  • Google L4 SWE Phone Screen: 1 Experience
  • Google ML Engineering Manager Onsite: 1 Experience
  • Google Experienced SWE First Round and Onsite: 1 Experience
All Google interview questionsSee Google hiring insights
Saved
class Solution {
    public int[][] peakTaskConcurrency(int[][] tasks) {
        // Write your code here.
    }
}
Checking account…