Job scheduling with pickup deadlines
A print shop runs one press. job_names lists the jobs waiting, every name is distinct and no name holds a comma or a space. run_minutes[i] is how long job i occupies the press and pickup_minutes[i] is the minute a courier collects that job, both counted from the moment the press starts. The press works the jobs one after another with no gaps, starting at minute 0, and a job is on time when it finishes at or before its own pickup minute. Every job must run. Return the running order that keeps every job on time, written as the job names joined by a comma and a space. When more than one order works, return the one that comes first alphabetically, comparing the orders job by job. Return an empty string when no order works, and when there are no jobs. There are at most 7 jobs and every minute given is positive.
on_time_press_order(job_names: list[str], run_minutes: list[int], pickup_minutes: list[int]) → str[["a","b","c"],[3,5,2],[10,5,12]]out"b, a, c"[["cards","banner"],[15,15],[15,20]]out""[["flyer","poster"],[20,10],[30,40]]out"flyer, poster"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.
[["a","b","c"],[3,5,2],[10,5,12]]"b, a, c"not run yetsample[["cards","banner"],[15,15],[15,20]]""not run yetsample[["flyer","poster"],[20,10],[30,40]]"flyer, poster"not run yetsample