Simplest Solution | Binary Search On Answer | Ignore Threshold
Intuition & ApproachInstead of checking if node 0 is reachable from all other nodes, we can reverse the edges and only check if all other nodes are reachable fr
# Intuition & Approach
Instead of checking if node 0 is reachable from all other nodes, we can reverse the edges and only check if all other nodes are reachable from node 0.

We can ignore the threshold condition because we only require one edge from each node to reach the destination.

By performing a binary search on the edge weights, we can efficiently find the required answer.


# Code
```java []
class Solution {
    public int minMaxWeight(int n, int[][] edges, int threshold) {
        ArrayList<Integer> list = new ArrayList<>();
        
        ArrayList<Pair>[] graph = new ArrayList[n];
        for(int i=0;i<n;i++)graph[i]=new ArrayList<>();
        
        for(int i=0;i<edges.length;i++){
            list.add(edges[i][2]);
            int u = edges[i][0];
            int v = edges[i][1];
            int w = edges[i][2];
            //reverse edge
            graph[v].add(new Pair(u, w));
        }
        //sort edges weights
        Collections.sort(list);
        int ans=-1;
        int l=0, r=edges.length-1;
        //binary search on answer
        while(l<=r){
            int mid = (l+r)/2;
            int midVal = list.get(mid);
            if(pf(graph, midVal, n)){
                ans = midVal;
                r=mid-1;
            }else{
                l=mid+1;
            }
        }
        return ans;
    }
    public boolean pf(ArrayList<Pair>[] graph, int maxW, int n){
        boolean ans = true;

        boolean[] visited = new boolean[n];

        dfs(0, maxW, graph, visited);
        
        for(boolean val:visited)ans=(ans&val);

        return ans;
    }
    //dfs to check if every node is reacheable from 0 or not
    public void dfs(int node, int maxW, ArrayList<Pair>[] graph, boolean[] visited){
        
        if(visited[node])return;
        
        visited[node]=true;
        for(Pair child: graph[node]){
            if(child.w<=maxW){
               dfs(child.v, maxW, graph, visited);
            }
        }
    }
}
//helper class
class Pair {
    int v,w;
    Pair(int v, int w){
        this.v=v;
        this.w=w;
    }
}
```
['Java']