Simple Solution || Beats 100% in both Time and Space || O(E logV) Time
IntuitionWe will reverse the graph first, and then we just need to find min weight to reach every node starting from 0. If we can't reach every node, return -1.
# Intuition
We will reverse the graph first, and then we just need to find min weight to reach every node starting from 0. If we can't reach every node, return -1. Else, the max weight we encountered so far.

# Approach
We can use a min heap to store min weight to reach every node, starting from 0 we will push (0,0) in our heap and then move on to adjacent nodes using BFS.
When we take the top element of our min heap, we are ensured that the top node cannot be reached from a edge having a weight < currentWeight.
Hence, this approach works.

# Complexity
- Time complexity: O(E logV) due to BFS using priority queue.

- Space complexity: O(V + E) due to visited array and priority queue.

# Code
```cpp []
class Solution {
public:
    int minMaxWeight(int n, vector<vector<int>>& edges, int threshold) {
        vector<pair<int,int>>* revAdj = new vector<pair<int,int>>[n]; // v, wt

        for (auto &e : edges) {
            int u = e[0], v = e[1], wt = e[2];
            revAdj[v].push_back({u, wt});
        }

        priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> pq; // minWtToReach, node
        vector<int> vis(n, 0);

        pq.push({0, 0});

        int mxwt = 0;

        while (!pq.empty()) {
            auto [weight, node] = pq.top();
            pq.pop();

            // "weight" is the minimum weight which can be used to reach "node" from 0

            if (vis[node])
                continue;

            vis[node] = 1;
            mxwt = max(mxwt, weight);

            for (auto& [adjNode, wt] : revAdj[node]) {
                if (!vis[adjNode]) {
                    pq.push({wt, adjNode});
                }
            }
        }

        // check if all nodes are visited, n 1's mean all nodes are visited
        int cnt = accumulate(vis.begin(), vis.end(), 0);
        return ((cnt == n) ? mxwt : -1);
    }
};
```
['Breadth-First Search', 'Graph', 'Heap (Priority Queue)', 'C++']