Gossip build propagation
A release tool ships a new build across several clusters by gossip. In each cluster one seed machine holds the build before the first round. During a round, every machine that already has the build sends it to fanout machines that do not have it yet, and the senders coordinate so no machine is sent the same build twice. A machine that receives the build in a round can forward it in the next one. cluster_sizes[i] is the number of machines in cluster i. Return a list holding, for each cluster in input order, the number of rounds until every machine in that cluster has the build. A cluster of one machine, or of none, needs no rounds. When fanout is 0 nothing ever spreads, so report -1 for any cluster of two or more machines.
rollout_rounds_needed(cluster_sizes: list[int], fanout: int) → list[int][[1,2,3,10],1]out[0,1,2,4][[9,10,27,28],2]out[2,3,3,4][[5,1,0],0]out[-1,0,0]State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
[[1,2,3,10],1][0,1,2,4]not run yetsample[[9,10,27,28],2][2,3,3,4]not run yetsample[[5,1,0],0][-1,0,0]not run yetsample