This function calculates the waiting time of some processes that have a specified duration time. Return: The waiting time for each process. >>> calculate_waiting_times([5, 10, 15]) [0, 5, 15] >>> calculate_waiting_times([1, 2, 3, 4, 5]) [0, 1, 3, 6, 10] >>> calcu
(duration_times: list[int])
| 6 | |
| 7 | |
| 8 | def calculate_waiting_times(duration_times: list[int]) -> list[int]: |
| 9 | """ |
| 10 | This function calculates the waiting time of some processes that have a |
| 11 | specified duration time. |
| 12 | Return: The waiting time for each process. |
| 13 | >>> calculate_waiting_times([5, 10, 15]) |
| 14 | [0, 5, 15] |
| 15 | >>> calculate_waiting_times([1, 2, 3, 4, 5]) |
| 16 | [0, 1, 3, 6, 10] |
| 17 | >>> calculate_waiting_times([10, 3]) |
| 18 | [0, 10] |
| 19 | """ |
| 20 | waiting_times = [0] * len(duration_times) |
| 21 | for i in range(1, len(duration_times)): |
| 22 | waiting_times[i] = duration_times[i - 1] + waiting_times[i - 1] |
| 23 | return waiting_times |
| 24 | |
| 25 | |
| 26 | def calculate_turnaround_times( |
no outgoing calls
no test coverage detected