#3419
Minimize the Maximum Edge Weight of Graph
specialist · 965 · lc medium +32 · 44% accepted · 242 likes · top 26%
Description
You are given integers n and threshold, and a directed weighted graph of n nodes (numbered 0 to n - 1). The graph is represented by a 2D array edges where edges[i] = [Ai, Bi, Wi] denotes an edge from node Ai to node Bi with weight Wi.
Remove edges (possibly none) so that:
- Every node can reach node 0.
- The maximum edge weight in the remaining graph is minimized.
- Each node has at most threshold outgoing edges.
Return the minimum possible value of the maximum edge weight. If the conditions cannot all be satisfied, return -1.
Code
1
2
3