Merge boarding lines
A gate agent boards a flight from two lines that are each already in order. priority_names lists the priority line and priority_secs gives the second each of those passengers scanned a pass, nondecreasing. general_names and general_secs say the same for the general line. Each name list matches its own second list in length. Merge the two lines into one boarding order by scan second, earliest first. When a priority passenger and a general passenger scanned in the same second, the priority passenger boards first. Passengers standing in the same line keep the order they are given, including when several of them scanned in the same second. Return the seat labels in boarding order. Either line can be empty, and two empty lines return an empty list. Both lines can be long, so aim for a single pass down the pair.
interleave_boarding_queues(priority_names: list[str], priority_secs: list[int], general_names: list[str], general_secs: list[int]) → list[str][["P-12A","P-3C"],[10,30],["G-21B","G-19F","G-30D"],[5,10,40]]out["G-21B","P-12A","G-19F","P-3C","G-30D"][["P-1A","P-1B","P-1C"],[0,0,5],["G-2A","G-2B"],[0,5]]out["P-1A","P-1B","G-2A","P-1C","G-2B"]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.
[["P-12A","P-3C"],[10,30],["G-21B","G-19F","G-30D"],[5,10,40]]["G-21B","P-12A","G-19F","P-3C","G-30D"]not run yetsample[["P-1A","P-1B","P-1C"],[0,0,5],["G-2A","G-2B"],[0,5]]["P-1A","P-1B","G-2A","P-1C","G-2B"]not run yetsample