
Arrival time: Time at which the process arrives.
Burst time: The time the process takes for its execution.
Completion time: Time at which the process completes its execution.
Turn Around time: Time difference between the Completion time and the Arrival time.
Waiting time: Time difference between the Turn Around time and the Burst time.
You can consider Arrival time for every process to be 0.
The first line contains a single integer 'T' representing the number of test cases.
The 'T' test cases are as follows:
The first line contains two integers 'N' and 'S' denoting the number of processes and time slice / quantum for performing round-robin scheduling respectively.
The second line contains 'N' space-separated integers, where the ith element denotes the Burst time for process 'i'.
For each test case, return the list that contains 'N' integers where ith element denotes the Waiting time for process 'i'.
You do not need to print anything, it has already been taken care of. Just implement the given function.
1 <= T <= 10
1 <= N <= 10^2
1 <= Time slice <= 10^2
1 <= Burst time <= 10^3
Time Limit: 1 sec
The problem can be solved by storing the remaining burst times in a separate array say rem and iterate over all the processes again and again until all the processes are completely executed (all the elements of rem become 0).
Let us understand it by an example:
For a time slice of 2 seconds and process array of size 3 as [ 5, 4, 3 ]
Initially, 'Time' = 0, rem array and 'WAITING' array are as follows:

For the first iteration of all the processes:

For the second iteration of all the processes:

For the third iteration of all the processes:

As all the processes are completed, we end our function.