C++ | Dijkrta's Algo
Code

# Code
```cpp []
class Solution {
public:
    vector<int> shortestPath(vector<vector<pair<int,int>>>&g)
    {
        priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> pq;
        int n=g.size(),vis=0;
        vector<int>dist(n,INT_MAX);
        pq.push({0,0});
        while(!pq.empty() && vis<n)
        {
            int d=pq.top().first,u=pq.top().second;
            pq.pop();
            if(dist[u]!=INT_MAX)
                continue;
            dist[u]=d;  
            vis++;  
            for(auto &p:g[u])
            {
                int v=p.first,w=p.second;
                if(dist[v]==INT_MAX)
                {
                    pq.push({max(d,w),v});
                }
            }
        }
        return dist;     
    }
    int minMaxWeight(int n, vector<vector<int>>& edges, int th) 
    {
        int res=-1;
        vector<vector<pair<int,int>>>g(n);
        for(auto &e:edges)
            g[e[1]].push_back({e[0],e[2]});  //Reverse edge
        
        auto dist = shortestPath(g);
        res=*max_element(dist.begin(),dist.end());
        if(res==INT_MAX)
            res=-1;
        return res;
    }
};
```
['Shortest Path', 'C++']