C++ | Prim | O(V+E)
Code

# Code
```cpp []
class Solution{
public:
    int minMaxWeight(int n, vector<vector<int>>& edges, int threshold){
        vector<unordered_map<int, int>> G(n);
        for(auto& e: edges){
            int u = e[0], v = e[1], w = e[2];
            if(G[v].contains(u)) G[v][u] = min(G[v][u], w);
            else G[v][u] = w;
        }
        int res = 0;
        priority_queue<pair<int,int>, vector<pair<int,int>>, greater<>> pq;
        pq.emplace(0,0);
        unordered_set<int> visited;
        while(pq.size()){
            auto [w, u] = pq.top();
            pq.pop();
            if(visited.contains(u)) continue;
            visited.insert(u);
            res = max(res, w);
            for(auto& [v,w]: G[u]){
                pq.emplace(w,v);
            }
        }
        return visited.size() == n ? res : -1;
    }
};
```
['C++']