Implement a semaphore limiting concurrent async ops to max.
max
solve(max, durations) simulates each duration with setTimeout underthe semaphore. Returns total elapsed time (ms) across all tasks.
solve(max, durations)
setTimeout
Sample tests