BFS || C++
Code
# Code
```cpp []
class Solution 
{
public:
    int minMaxWeight(int n, vector<vector<int>>& edges, int threshold) 
    {
        vector<pair<int,int>> adj[n];
        for(auto e: edges)
        {
            adj[e[1]].push_back({e[0],e[2]});
        }
        priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> q;
        vector<int> vis(n,0);
        q.push({0,0});
        int ans=0;
        while(!q.empty())
        {
            auto p=q.top();
            q.pop();
            int node=p.second, curr=p.first;
            if(vis[node]) continue;
            ans=max(ans,curr);
            vis[node]=1;
            for(auto it: adj[node])
            {
                int neigh=it.first, dist=it.second;
                if(!vis[neigh]) q.push({dist,neigh});
            }
        }
        for(auto i: vis) if(!i) return -1;
        return ans;
    }
};
```
['Breadth-First Search', 'C++']