Practice Minimize the Maximum Edge Weight of Graph
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Minimize the Maximum Edge Weight of Graph
Problem Statement
Given a directed graph with edges [from, to, weight], n nodes numbered 0 through n - 1, and threshold, remove edges so that every node can reach node 0 and every node has at most threshold outgoing edges. Among graphs meeting both conditions, minimize the largest remaining edge weight. Return that minimum, or -1 if impossible.
Source: Minimize the Maximum Edge Weight of Graph on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
n = 5, edges = [[1,0,1],[2,0,2],[3,0,1],[4,3,1],[2,1,1]], threshold = 2
1
# Example 2
n = 5, edges = [[0,1,1],[0,2,2],[0,3,1],[0,4,1],[1,2,1],[1,4,1]], threshold = 1
-1
# Example 3
n = 5, edges = [[1,2,1],[1,3,3],[1,4,5],[2,3,2],[3,4,2],[4,0,1]], threshold = 1
2
# Example 4
n = 5, edges = [[1,2,1],[1,3,3],[1,4,5],[2,3,2],[4,0,1]], threshold = 1
-1
Constraints
Related LeetCode Problems
Practice more problems similar to Minimize the Maximum Edge Weight of Graph.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.