Code RoomPrint queue with rush lanes
EasyPrep Room Coding #4728

Print queue with rush lanes

CodingAlgorithms & data structuresEntry–Mid~14 min

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.

Implement
spool_print_order(events: list[str]) → list[str]
Examples
in[["queue|a|normal","queue|b|rush","print","print"]]out["b","a"]
in[["queue|a|normal","print","queue|b|rush","print"]]out["a","b"]
in[["print","queue|x|rush","queue|y|rush","print","print","print"]]out["x","y"]
What a strong answer looks like

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.

0:00 of about 14 min
InputExpectedGot
[["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