Print queue with rush lanes
An office print server replays the event log of one morning. Every event is either the single word "print" or an arrival written as "queue|payroll|normal", where the second field is a document name and the third field is the lane, either "normal" or "rush". A normal document joins the back of the spool. A rush document goes ahead of every normal document already waiting, but behind every rush document already waiting, so rush documents keep their own arrival order. A "print" event sends the document at the front of the spool to the printer and removes it, and does nothing when the spool is empty. Names may repeat. Return the document names in the order they were printed.
spool_print_order(events: list[str]) → list[str][["queue|a|normal","queue|b|rush","print","print"]]out["b","a"][["queue|a|normal","print","queue|b|rush","print"]]out["a","b"][["print","queue|x|rush","queue|y|rush","print","print","print"]]out["x","y"]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.
[["queue|a|normal","queue|b|rush","print","print"]]["b","a"]not run yetsample[["queue|a|normal","print","queue|b|rush","print"]]["a","b"]not run yetsample[["print","queue|x|rush","queue|y|rush","print","print","print"]]["x","y"]not run yetsample