Network bottleneck bandwidth

Write codeMedium28 minCisco style

Your task

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.

Examples

backbone_bandwidths(site_count: int, link_from: list[int], link_to: list[int], link_gbps: list[int]) -> list[int]
Example 1
Inputbackbone_bandwidths(4, [0, 1, 0], [1, 2, 3], [10, 4, 6])
Output[0, 10, 4, 6]
Example 2
Inputbackbone_bandwidths(4, [0, 1, 2, 0], [1, 2, 3, 3], [10, 10, 10, 2])
Output[0, 10, 10, 10]
Example 3
Inputbackbone_bandwidths(3, [0, 0], [1, 1], [5, 9])
Output[0, 9, 0]