[C++] 90%, Dijkstra
IntuitionReverse the edges of the graph. This simplifies the reachability problem. Then we run dijkstra algo, but a variant where we try to minimize the the wei
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
Reverse the edges of the graph. This simplifies the reachability problem. Then we run dijkstra algo, but a variant where we try to minimize the the weight of an edge chosen to reach some node n. On top of that, we have the constraint that in_degree (because graph is reversed) should be <= threshold.

To put it more simply, at any point, say we know the solution for some subset of nodes (reachable from node 0 and minimized weights). Then out of all the possible outgoing edges from this set, we choose the one with:
- Min edge weight
- Satisfying the condition that in_deg <= threshold
But what if there's some edge to our current set of nodes which is even smaller ? Doesn't matter, as we take the maxm either way
# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
O(V + ElogV)
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```cpp []
class Solution {
public:
    // Custom Dijkstra?

    int minMaxWeight(int n, vector<vector<int>>& edges, int threshold) {
       
        vector<vector<pair<int, int>>> g(n);
        for (auto& e: edges) {
            g[e[1]].push_back({e[0], e[2]});
        }    

        struct Node {
            int u, v, w;
            bool operator<(const Node& other) const {
                return w > other.w;
            }
        };

        priority_queue<Node> pq;

        pq.push({-1, 0, 0});
     
        vector<int> par(n, INT_MAX);
        par[0] = 0;

        vector<int> in_degree(n);
        vector<bool> vis(n);
        while (!pq.empty()) {
            auto top = pq.top();
            pq.pop();
            
            int u = top.v, w = top.w;
            int from = top.u;
            if (vis[u]) continue;
            par[u] = w;
            // cout << from << " " << u << " " << w << "\n";
            vis[u] = true;
            in_degree[u]++;
            for (auto& e: g[u]) {
                int v = e.first;
                if (e.second < par[v] && in_degree[v] <= threshold && !vis[v]) {
                    pq.push({u, v, e.second});
                }
              
            }
        }
        int ans = 0;
        for (int w: par) {
            if (w == INT_MAX) return -1;
            ans = max(ans, w);
        }
        return ans;
    }
};
```
['C++']