Solution with BFS+Binary Search1 | Easily understandable | 
Complexity
Time complexity:

O(log(maxi) * (V+E))
Code

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- **O(log(maxi) * (V+E))**

---

# Code
```cpp []
class Solution {
public:
    bool isPossibleToZero(int n,vector<vector<pair<int,int>>>&adj,int mid){
        queue<int> q;
        vector<bool> vis(n) ;
        q.push(0) ;
        vis[0]=true ;
        while(!q.empty()){
            int u=q.front() ;
            q.pop() ;
            for(pair p : adj[u]){
                int v=p.first ;
                int w=p.second ;
                if(w<=mid && !vis[v]){
                    vis[v]=true ;
                    q.push(v);
                }
            }
        }
        for(int i=0;i<n;i++){
            if(!vis[i]){
                return false; 
            }
        }
        return true;
    }

    int minMaxWeight(int n, vector<vector<int>>& edges, int threshold) {
        vector<vector<pair<int,int>>> adj(n) ;
        int maxWt=0 ;
        for(int i=0;i<edges.size();i++){
            int u=edges[i][0] ;
            int v=edges[i][1] ;
            int w=edges[i][2] ;

            adj[v].push_back({u,w}) ;
            maxWt=max(w,maxWt) ;
        }
        int result=INT_MAX;
        int l=0,r=maxWt ;
        while(l<=r){
            int mid=l+(r-l)/2 ;
            if(isPossibleToZero(n,adj,mid)){
                result=mid; 
                r=mid-1 ;
            }else{
                l=mid+1 ;
            }
        }
        return result==INT_MAX?-1:result ;
    }
};
```
['C++']