Simple and Easy Java Code
IntuitionDo binary search as it is mentioned to find the The maximum edge weight in the resulting graph is minimized.
-> reverse the edges so that we know wheth
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
 Do binary search as it is mentioned to find the The maximum edge weight in the resulting graph is minimized.
-> reverse the edges so that we know whether we reach 0 node or not, haha yes I have done this cleverly, I have used dijkshtras to know it is possible or not

# Code
```java []
class Solution {
    
    public int minMaxWeight(int n, int[][] edges, int threshold) {
        
        ArrayList<ArrayList<Pair>> adj=new ArrayList<>();
        for(int i=0;i<n;i++){
            adj.add(new ArrayList<>());
        }
        int min=Integer.MAX_VALUE;
        int max=Integer.MIN_VALUE;
        for(int i=0;i<edges.length;i++){
            int dist=edges[i][2];
            adj.get(edges[i][1]).add(new Pair(edges[i][0], edges[i][2]));
            min=Math.min(min, dist);
            max=Math.max(max, dist);
        }

        int ans=-1;
        while(min<=max){
            int mid=(min+max)/2;
            if(isPossible(adj, mid)){
                ans=mid;
                max=mid-1;
            } else{
                min=mid+1;
            }
        }
        return ans;

    }

    private boolean isPossible(ArrayList<ArrayList<Pair>> adj, int maxEdge){

        int n=adj.size();
        int[] movement = new int[n];
        Arrays.fill(movement, Integer.MAX_VALUE);
        movement[0]=0;
        PriorityQueue<Pair> pq = new PriorityQueue<>(new Comparator<Pair>(){
            public int compare(Pair p, Pair q){
                return p.dist-q.dist;
            }
        });
        pq.add(new Pair(0, 0));
        while(pq.size()>0){
            Pair pair=pq.poll();
            int ver=pair.ver;
            int dist=pair.dist;
            for(int j=0;j<adj.get(ver).size() ; j++){
                int nextVer = adj.get(ver).get(j).ver;
                int nextDist = adj.get(ver).get(j).dist;
                if(movement[nextVer]> dist+nextDist && nextDist <= maxEdge){
                    movement[nextVer] = dist+nextDist;
                    pq.add(new Pair(nextVer, movement[nextVer]));
                }
                
            }
        }
        
        for(int i=0;i<n;i++){
            if(movement[i]==Integer.MAX_VALUE){
                return false;
            }
        }
        return true;
    }

    class Pair{
        int ver;
        int dist;
        Pair(int ver, int dist){
            this.ver=ver;
            this.dist=dist;
        }
    }
}
```
# DO UPVOTE IF YOU FOUND THIS HELPFUL 😀


['Java']