Print queue with rush lanes
Your task
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.
Examples
spool_print_order(events: list[str]) -> list[str]Example 1
Input
spool_print_order(["queue|a|normal", "queue|b|rush", "print", "print"])Output
["b", "a"]Example 2
Input
spool_print_order(["queue|a|normal", "print", "queue|b|rush", "print"])Output
["a", "b"]Example 3
Input
spool_print_order(["print", "queue|x|rush", "queue|y|rush", "print", "print", "print"])Output
["x", "y"]