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
Coding & Algorithms
Software Engineer
Cognizant
November 29, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Medium

0

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
heaps
discrete event simulation
queues
SLA modeling
scheduling
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. 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 Problems
Sample 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...


Submit Your Answer
Markdown supported

Related Questions