Javascript | Prim | O(V+E)
Code
# Code
```javascript []
/**
 * @param {number} n
 * @param {number[][]} edges
 * @param {number} threshold
 * @return {number}
 */
var minMaxWeight = function(n, edges, threshold) {
    const G = Array(n).fill(0).map(()=>new Map());
    for(const [u,v,w] of edges)
        G[v].set(u, Math.min(G[v].get(u) ?? Infinity, w));
    let res = 0;
    const pq = new PriorityQueue({compare: (x,y) => x[0] - y[0]});
    pq.enqueue([0,0]);
    const visited = new Set();
    while(pq.size()){
        const [w, u] = pq.dequeue();
        if(visited.has(u)) continue;
        res = Math.max(res, w);
        visited.add(u);
        for(const [v, w] of G[u]){
            pq.enqueue([w,v]);
        }
    }
    console.log("check", visited.size);
    return visited.size === n ? res : -1;
};
```
['JavaScript']