Peak Chat Load Across Agents
Updated
Problem statement
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) andbo'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 5boadds 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 <= 2000agents.length == periods.length- Each
agents[i]is 1 to 10 lowercase English letters or digits. periods[i].length == 30 <= start <= end <= 1091 <= 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