Round-Robin Assignment
This is how simple load balancers work: the first task goes to the first server, the next task to the second server, and so on in a cycle. Given the number of tasks tasks and the number of servers servers, return a list of length tasks showing which server index handles each task. Server indices go from 0 to servers - 1. If there are no tasks, return an empty list.
Примеры
Ввод
5, 2Вывод
[0, 1, 0, 1, 0]Ввод
0, 3Вывод
[]Ввод
3, 3Вывод
[0, 1, 2]Нужно реализовать
def round_robin(tasks, servers):
Теги
arraylistsmath
Přihlaste se, abyste viděli historii odevzdání
Přihlásit sePřihlaste se, abyste mohli použít AI mentora
Přihlásit seVisible tests
1
Input
5, 2Expected
[0,1,0,1,0]2
Input
0, 3Expected
[]3
Input
3, 3Expected
[0,1,2]4
Input
4, 1Expected
[0,0,0,0]5
Input
7, 3Expected
[0,1,2,0,1,2,0]6
Input
1, 3Expected
[0]Focus radio
Paused · SomaFM · Fluid