Network bottleneck bandwidth
A carrier joins its sites with bidirectional fibre. Link j runs between sites link_from[j] and link_to[j] and carries link_gbps[j] gigabits per second. Traffic leaves the core, which is site 0. A route is only as fast as its narrowest link, so the bandwidth of a route is the smallest capacity along it, and the bandwidth to a site is the best that any route from the core can offer. Return a list of length site_count whose entry i is the bandwidth to site i. Use 0 for the core itself and 0 for any site the core cannot reach. Capacities are positive, and two sites may be joined by more than one link.
backbone_bandwidths(site_count: int, link_from: list[int], link_to: list[int], link_gbps: list[int]) → list[int][4,[0,1,0],[1,2,3],[10,4,6]]out[0,10,4,6][4,[0,1,2,0],[1,2,3,3],[10,10,10,2]]out[0,10,10,10][3,[0,0],[1,1],[5,9]]out[0,9,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.
[4,[0,1,0],[1,2,3],[10,4,6]][0,10,4,6]not run yetsample[4,[0,1,2,0],[1,2,3,3],[10,10,10,2]][0,10,10,10]not run yetsample[3,[0,0],[1,1],[5,9]][0,9,0]not run yetsample