FastPrepPeak Chat Load Across Agents
Problems/Peak Chat Load Across Agents

Peak Chat Load Across Agents

Cresta logoCresta● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Cresta asked this in the problem-solving coding round of a senior software engineer phone screen. Each agent has active periods given as a start time, an end time (both included) and a number of chats. The load at a time is the sum of chats of all periods covering it. The task was to find the highest load and a time when it happens. The candidate used a sweep line that adds chats at the start and removes them one step after the end, and kept the earliest time on ties.

The report left out the input shape and limits. Our choices: times are integers, and the per-agent dictionary is given as parallel arrays of agent names and [start, end, chats] periods. The answer is [maxLoad, earliest time]. Agent names are 1 to 10 lowercase letters or digits. The limits are up to 2000 periods, times from 0 to 10^9 and 1 to 1000 chats per period.

Our version is about 90% the same as the reported question.

A contact center tracks how many chats its agents handle. Period i belongs to agent agents[i] and is periods[i] = [start, end, chats]: during every integer time t with start <= t <= end (both ends included), that agent handles chats chats. One agent can have several periods, and they may overlap.

The load at time t is the total chats of all periods, from all agents, that contain t.

Return [maxLoad, time], where maxLoad is the largest load at any time and time is the earliest time at which that load occurs.

Function

peakChatLoad(agents: String[], periods: int[][]) → int[]

Examples

Example 1

agents = ["ann","ann","bo"]periods = [[1,3,2],[5,6,4],[3,5,1]]return = [5,5]
  • At time 3, ann's first period (2 chats) and bo's period (1 chat) are both active: load 3.
  • At times 5 and 6, ann's second period (4 chats) is active, and at time 5 bo adds 1: load 5 at time 5, the maximum. The answer is [5, 5].

Example 2

agents = ["a","b"]periods = [[0,4,3],[5,9,3]]return = [3,0]
  • The two periods do not overlap (time 4 is the last time of the first one), so the maximum load is 3. It first happens at time 0, so the answer is [3, 0].

Example 3

agents = ["x"]periods = [[7,7,9]]return = [9,7]
  • One period that covers only time 7: [9, 7].

Constraints

  • 1 <= periods.length <= 2000
  • agents.length == periods.length
  • Each agents[i] is 1 to 10 lowercase English letters or digits.
  • periods[i].length == 3
  • 0 <= start <= end <= 109
  • 1 <= chats <= 1000

More Cresta interview questions

  • File Storage ServicePHONE SCREEN · Seen Nov 2026
  • Dynamic Least-Loaded Job DispatcherPHONE SCREEN · Seen Oct 2026
  • Decode Words with Anagram KeysOA · Seen Oct 2026
  • Find a File in a Directory SnapshotOA · Seen Oct 2026
  • Leaves Remaining After WindOA · Seen Oct 2026
  • Maximum Suffix–Prefix OverlapOA · Seen Oct 2026
  • Particle Moves to TargetOA · Seen Jul 2026
  • Rightward Bacteria ConsumptionOA · Seen Jul 2026
  • Top Three Companies by ProfitOA · Seen Jul 2026
  • Feature Flag Evaluation EngineONSITE INTERVIEW · Seen Jul 2026

Similar questions at other companies

  • Majority Labels over Audio IntervalsNooks · PHONE SCREEN
  • Merge Overlapping IntervalsAtlassian · PHONE SCREEN · ONSITE INTERVIEWAtlassian interview questions
  • Meeting Rooms IIeBay · PHONE SCREENeBay interview questions
  • Meeting Rooms IIByteDance · PHONE SCREENByteDance interview questions
  • Meeting Rooms IIUber · PHONE SCREENUber interview questions
  • Merge IntervalsGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
  • Merge Overlapping IntervalsFurtherAI · PHONE SCREEN
  • Peak Resource Usage Across Weighted IntervalsTekion · PHONE SCREENTekion interview questions
  • Merge Overlapping IntervalsFox Corporation · PHONE SCREEN
  • Longest Uninterrupted Work BlockIntuit · PHONE SCREENIntuit interview questions

Interview reports that mention this question

  • Cresta Senior SWE Coding Round Interview Experience: 1 Experience
All Cresta interview questionsSee Cresta hiring insights
Saved
class Solution {
    public int[] peakChatLoad(String[] agents, int[][] periods) {
        // Return {maxLoad, earliest time of that load}.
    }
}
Checking account…