Minimum worker pool size
Your task
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.
Examples
pool_size_for_wait_cap(arrival_seconds: list[int], job_seconds: int, wait_cap: int) -> intExample 1
Input
pool_size_for_wait_cap([0, 0, 0, 5, 5], 4, 3)Output
3Example 2
Input
pool_size_for_wait_cap([0, 10, 20, 30], 7, 0)Output
1Example 3
Input
pool_size_for_wait_cap([0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 15)Output
5