Simulate Support Ticket Assignment Across a Fixed Agent Pool
Last updated: November 29, 2026
Quick Overview
Tickets arrive in time order with a handling duration. With k agents, each ticket goes to the free agent with the lowest ID; if none is free it waits in a FIFO queue. Return each ticket's assigned agent and start time.
Cognizant
November 29, 20260
0
0 solved
Tickets arrive in time order with a handling duration. With k agents, each ticket goes to the free agent with the lowest ID; if none is free it waits in a FIFO queue. Return each ticket's assigned agent and start time.
Cognizant runs large managed support desks for clients, where staffing decisions depend on simulated queue behavior and SLA risk. This question checks event-driven simulation with two heaps and a queue, and careful handling of a release and an arrival at the same timestamp.
What the Interviewer Expects
- Keeps a min-heap of free agent IDs and a min-heap of (free_at, agent)
- Advances time to the next event instead of ticking every unit
- Releases agents before admitting arrivals at the same time
- Preserves FIFO order for waiting tickets
- Explains O(n log k) cost
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- Tickets now have priorities P1 to P4 and higher priority jumps the queue. What changes?
- How would you compute the fraction of P1 tickets that breach a 30 minute response SLA?
- How would you use this simulator to pick the minimum k for a target SLA?
- Agents have skills and tickets have categories. How does assignment change?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Input: k agents numbered from 0 and tickets as (id, arrival, duration) sorted by arrival. A ticket starts at the first moment it is at the head of the queue and some agent is free; the lowest fr...
High-Level Design
State: free (heap of agent IDs), busy (heap of (free_at, agent)), waiting (deque). Each loop picks the next event time: if tickets are waiting, the next useful moment is the earlier of the nex...