Very Easy Java code
Code


# Code
```java []
class Solution {
    public int minMaxWeight(int n, int[][] edges, int threshold) {
        ArrayList<ArrayList<int[]>> adj = new ArrayList<>();
        for(int i=0;i<n;i++) adj.add(new ArrayList<>());
        for(int j=0;j<edges.length;j++){
            //dest,wt
            adj.get(edges[j][1]).add(new int[]{edges[j][0],edges[j][2]});
        }
        PriorityQueue<int[]> pq = new PriorityQueue<>((a,b)->{
            return a[2]-b[2];
        });
        // src,par,wt
        pq.add(new int[]{0,-1,0});
        int ans=0;
        boolean vis[]=new boolean[n];
        while(!pq.isEmpty()){
            int arr[]=pq.remove();
            int src=arr[0],par=arr[1],wt=arr[2];
            if(par!=-1&&!vis[src]) ans=Math.max(ans,wt);
            vis[src]=true;
            for(int i[]:adj.get(src)){
                if(!vis[i[0]]){
                    pq.add(new int[]{i[0],src,i[1]});
                }
            }
        }
        for(int i=0;i<n;i++){
            if(!vis[i]) return -1;
        }
        return ans;
    }
}
```
['Java']