Simple and Easy Solution || (Using Only Priority Queue) Beats 99% ✅✅
Code
# Code
```cpp []
class Solution {
public:
    int minMaxWeight(int n, vector<vector<int>>& edges, int threshold) {
        int m=edges.size();
        vector<pair<int,int>> adj[n];
        for(int i=0;i<m;i++){
            adj[edges[i][1]].push_back({edges[i][0],edges[i][2]});
        }
        vector<int> vis(n,0);
        priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>>pq;
        for(auto a:adj[0]){
            pq.push({a.second,a.first});    
        }
        vis[0]=1;
        int ans=INT_MIN;
        while(!pq.empty()){
            int w=pq.top().first;
            int node=pq.top().second;
            pq.pop();
            if(vis[node]){
                continue;
            }
            vis[node]=1;
            ans=max(ans,w);
            for(auto a:adj[node]){
                if(vis[a.first]==0){
                    pq.push({a.second,a.first});
                }
            }
        }
        for(int i=0;i<n;i++){
            if(vis[i]==0){
                return -1;
            }
        }
        return ans;
    }
};
```
['Heap (Priority Queue)', 'C++']