Binary Search || BFS || 
IntuitionBinary Search on weight and find it is possible to have weight minimm equal to mid value.
Then we check if zero is reachable from all nodes by ignoring
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
Binary Search on weight and find it is possible to have weight minimm equal to mid value.
Then we check if zero is reachable from all nodes by ignoring the wt greater then mid value.
For this we just reverse the all edge and check from zero where we can reach if we reach all node return true else return false.

The concept of reversing the edge is if we donot reverse the edge then we have to apply dfs/bfs each node check to reach zero ,this is time consuming solution
# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```java []
class Solution {
    class pair{
        int node;
        int wt;
        public pair(int node,int wt){
            this.node=node;
            this.wt=wt;
        }
    }
    public boolean canReachZero(List<List<pair>>adj,int mid,int n){
        boolean visited[]=new boolean[n];
        Queue<pair>q=new LinkedList<>();
        q.offer(new pair(0,0));
        visited[0]=true;
        while(!q.isEmpty()){
            pair top=q.poll();
            int node=top.node;
            int wt=top.wt;
            for(pair p:adj.get(node)){
                if(p.wt<=mid && visited[p.node]==false){
                    q.offer(new pair(p.node,p.wt));
                    visited[p.node]=true;
                }
            }
        }
        for(int i=0;i<n;i++){
            if(visited[i]==false)return false;
        }
        return true;
    }
    public int minMaxWeight(int n, int[][] edges, int threshold) {
      int max=0;
      List<List<pair>>adj=new ArrayList<>();
      for(int i=0;i<n;i++){
        adj.add(new ArrayList<pair>());
      }
      for(int e[]:edges){
        max=Math.max(max,e[2]);
        int u=e[0];
        int v=e[1];
        int w=e[2];
        adj.get(v).add(new pair(u,w));// we are reversing the all edges so that we can check from zero where we can reach from zero;

      }
      int high=max;
      int low=0;
      
      int ans=-1;
      while(low<=high){
        int mid=low+(high-low)/2;
        if(canReachZero(adj,mid,n)){
            ans=mid;
            high=mid-1;
        }else{
            low=mid+1;
        }
      } 
      return ans; 
    }
}
```
['Java']