Minimum worker pool size
A transcoder cuts an upload into fixed length chunks and hands them to a pool of identical workers. arrival_seconds lists the second each chunk reached the queue, sorted ascending and possibly with repeats, and every chunk occupies one worker for exactly job_seconds. Chunks leave the queue strictly in arrival order, and each one starts the moment a worker frees up. A chunk may wait at most wait_cap seconds between arriving and starting. Return the smallest pool size that holds every chunk inside that limit, and 0 when there are no chunks at all. Counting the chunks that land inside a single stretch of wait_cap plus job_seconds and dividing gives the wrong pool size, so the queue itself has to be modelled.
pool_size_for_wait_cap(arrival_seconds: list[int], job_seconds: int, wait_cap: int) → int[[0,0,0,5,5],4,3]out3[[0,10,20,30],7,0]out1[[0,0,0,0,0,0,0,0,0],10,15]out5State 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,0,0,5,5],4,3]3not run yetsample[[0,10,20,30],7,0]1not run yetsample[[0,0,0,0,0,0,0,0,0],10,15]5not run yetsample