Code RoomThread pool task completion times
MediumPrep Room Coding #173

Thread pool task completion times

CodingConcurrencyMid–Senior~30 min

A thread pool has `workers` identical worker threads. Tasks are submitted in order; task i has duration durations[i] and is submitted at submit_time times[i] (times is non-decreasing). When a task is submitted, if a worker is free it starts immediately; otherwise it waits in a FIFO queue and starts as soon as a worker frees up. Among queued tasks, the one submitted earlier starts first (ties broken by smaller index). Compute and return a list `finish` where finish[i] is the time task i completes. A task running for d units starting at time s finishes at s + d.

Implement
pool_finish_times(workers: int, times: list[int], durations: list[int]) → list[int]
Examples
in[1,[0,0,0],[5,3,2]]out[5,8,10]
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 30 min
InputExpectedGot
[1,[0,0,0],[5,3,2]][5,8,10]not run yetsample