Priority job batch
A batch runner holds every submitted job in one queue and drains part of it during each nightly maintenance window. job_names lists the jobs in the order they were submitted, and priorities[i] is the priority the operator gave job_names[i]. A larger priority starts sooner, and a priority may be negative for work that is content to wait. When two jobs carry the same priority, the one submitted earlier, meaning the smaller index, starts first, so the running order is fully determined. Tonight the window has room for slots jobs. Return the names of the jobs the runner starts, in the order it starts them. Return every job in running order when slots is larger than the queue, and an empty list when slots is zero or negative. Job names are not guaranteed to be unique.
scheduler_first_jobs(job_names: list[str], priorities: list[int], slots: int) → list[str][["reindex","backup","email"],[2,5,2],2]out["backup","reindex"][["alpha","beta","gamma"],[1,1,1],5]out["alpha","beta","gamma"][["nightly","hotfix"],[0,-3],1]out["nightly"]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.
[["reindex","backup","email"],[2,5,2],2]["backup","reindex"]not run yetsample[["alpha","beta","gamma"],[1,1,1],5]["alpha","beta","gamma"]not run yetsample[["nightly","hotfix"],[0,-3],1]["nightly"]not run yetsample