Code RoomOrder turnaround tasks
EasyPrep Room Coding #4826

Order turnaround tasks

CodingAlgorithms & data structuresEntry–Mid~18 min

A ground crew works a fixed list of turnaround tasks on a parked aircraft, one task at a time, and the dispatcher wants to see every workable running order before the shift starts. task_names lists the tasks, and every name is distinct. must_precede holds rules written as "fuel|board", meaning fuel has to finish before board may start. A rule can be listed more than once, and it always names two different tasks that both appear in task_names. Return every order that runs each task exactly once and breaks no rule, each written as the task names joined by a comma and a space. Return the orders sorted in ascending order, so the answer does not depend on how the list was typed. Return an empty list when there are no tasks, and when the rules contradict each other so that no order works. There are at most 7 tasks.

Implement
list_turnaround_orders(task_names: list[str], must_precede: list[str]) → list[str]
Examples
in[["fuel","clean","board"],["fuel|board"]]out["clean, fuel, board","fuel, board, clean","fuel, clean, board"]
in[["a","b"],["a|b","b|a"]]out[]
in[["tow","wash"],[]]out["tow, wash","wash, tow"]
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 18 min
InputExpectedGot
[["fuel","clean","board"],["fuel|board"]]["clean, fuel, board","fuel, board, clean","fuel, clean, board"]not run yetsample
[["a","b"],["a|b","b|a"]][]not run yetsample
[["tow","wash"],[]]["tow, wash","wash, tow"]not run yetsample