Rust Solution
IntuitionThe problem asks to find the minimum maximum weight of the edges such that there exists a path from node 0 to all other nodes, where the weight of the
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
The problem asks to find the minimum maximum weight of the edges such that there exists a path from node 0 to all other nodes, where the weight of the edges on the path does not exceed a certain threshold. This can be thought of as a graph traversal problem, where we need to determine the smallest possible maximum edge weight that allows traversal from node 0 to all other nodes.

# Approach
<!-- Describe your approach to solving the problem. -->
Graph Representation: We represent the graph using an adjacency list, where each node stores a list of its neighbors and the weight of the edge connecting them. Each edge is represented as a tuple (neighbor, weight).

Binary Search: We perform a binary search on the edge weights. The search range is from the smallest edge weight (mini) to the largest edge weight (maxi) found in the input edges. This helps us minimize the maximum edge weight while ensuring that all nodes are reachable from node 0.

DFS for Connectivity Check: For each mid-point value during the binary search, we check if it's possible to reach all nodes starting from node 0 using edges that do not exceed the current mid-point weight. This is done via a Depth First Search (DFS) traversal, where we only explore edges whose weight is less than or equal to the current mid-point.

Updating Binary Search Range: If it's possible to visit all nodes with the current mid-point weight, we try to find a smaller possible maximum weight by narrowing the search to the lower half. Otherwise, we increase the search range to check larger edge weights.

Termination: The binary search terminates when the search space is exhausted, and the smallest valid maximum edge weight is the answer.

# Complexity
- Time complexity: O(logW⋅(n+e))
W is the range of edge weights (from mini to maxi)
n is the number of nodes
e is the number of edges
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity: O(n+e)
n is the number of nodes
e is the number of edges
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```rust []
impl Solution {
    fn dfs(src: usize, adj: &Vec<Vec<(usize, i32)>>, vis: &mut Vec<bool>, mid: i32) {
        vis[src] = true;
        for &(neighbor, weight) in &adj[src] {
            if !vis[neighbor] && weight <= mid {
                Self::dfs(neighbor, adj, vis, mid);
            }
        }
    }
    fn check(src: usize, adj: &Vec<Vec<(usize, i32)>>, mid: i32, n: usize) -> bool {
        let mut vis = vec![false; n];
        Self::dfs(src, adj, &mut vis, mid);
        vis.iter().all(|&v| v)
    }
    pub fn min_max_weight(n: i32, edges: Vec<Vec<i32>>, threshold: i32) -> i32 {
        let n = n as usize;
        let mut adj = vec![vec![]; n];
        let mut mini = i32::MAX;
        let mut maxi = i32::MIN;
        for edge in edges {
            let u = edge[0] as usize;
            let v = edge[1] as usize;
            let w = edge[2];
            adj[v].push((u, w));
            mini = mini.min(w);
            maxi = maxi.max(w);
        }
        let mut low = mini;
        let mut high = maxi;
        let mut ans = -1;
        while low <= high {
            let mid = low + (high - low) / 2;
            if Self::check(0, &adj, mid, n) {
                ans = mid;
                high = mid - 1;
            } else {
                low = mid + 1;
            }
        }
        ans
    }
}

```
['Binary Search', 'Depth-First Search', 'Graph', 'Rust']