Chat agent assignment
A support desk staffs agent_count agents numbered from 0, and there is always at least one. Each entry of ops is either 'open 7' or 'close 7', where the number names one chat. An open hands the chat to whichever agent is carrying the fewest open chats right now, and a tie goes to the lowest agent number. A close ends that chat, so the agent carrying it drops one. A close naming a chat that is not currently open is ignored, and a chat is never opened twice while it is open. Return the agent number that took each open, in the order the opens appear. Return an empty list when no chat is ever opened.
chat_desk_routing(agent_count: int, ops: list[str]) → list[int][2,["open 1","open 2","open 3","close 1","open 4"]]out[0,1,0,0][3,["open 9","open 8","close 9","open 7"]]out[0,1,0][2,["open 1","open 2","close 2","close 1","open 3","open 4"]]out[0,1,0,1]State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
[2,["open 1","open 2","open 3","close 1","open 4"]][0,1,0,0]not run yetsample[3,["open 9","open 8","close 9","open 7"]][0,1,0]not run yetsample[2,["open 1","open 2","close 2","close 1","open 3","open 4"]][0,1,0,1]not run yetsample