Minimize maximum link latency
Your task
A network of n nodes (0..n-1) is connected by bidirectional links, each with a latency. You want to connect all nodes into one network while minimizing the single worst (maximum) latency among the links you use. Given edges as [latency, u, v], return the minimum possible value of the maximum link latency in a spanning structure that connects every node. If n <= 1 return 0; if the nodes cannot all be connected return -1.
Examples
min_bottleneck(n: int, edges: list[list[int]]) -> intExample 1
Input
min_bottleneck(4, [[1, 0, 1], [5, 1, 2], [2, 2, 3], [4, 0, 3]])Output
4