Dijkstra - Reverse Everything 
IntuitionInstead of ensuring all nodes in the directed graph can reach node 0, reverse the direction of the edges. This transforms the problem into checking whe
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
Instead of ensuring all nodes in the directed graph can reach node 0, reverse the direction of the edges. This transforms the problem into checking whether node 0 can reach all other nodes.
# Approach
<!-- Describe your approach to solving the problem. -->
maintain a variable ans to keep the track of max answer so far that you have encountered and for condition of outgoing edges on reversing it becomes incoming edges we can maintain a cnt array to keep track of it and that's it we should we good to go

# Complexity
- Time complexity:
 O(ElogE+(E+V)logV)

- Space complexity:
O(E+V)

# Code
```java []
class Solution {
    public int minMaxWeight(int n, int[][] e, int th) {
        List<int[]> g[] = new ArrayList[n];
        for(int i=0;i<n;i++)
            g[i]=new ArrayList<>();
        int[] cnt = new int[n];
        int[] vis = new int[n];
        for(int[] ed : e)
        {
            g[ed[1]].add(new int[]{ed[0],ed[2]});
        }
        for(int i=0;i<n;i++)
        {
            g[i].sort(Comparator.comparingInt(a -> a[1]));
        }
        int ans = 0;
        PriorityQueue<int[]> q = new PriorityQueue<>((q1,q2)->(q1[1]-q2[1]));
        q.add(new int[]{0,0});
        while(q.size() > 0)
        {
            int[] rem = q.poll();
            int node = rem[0];
            int wt = rem[1];
            if(vis[node] == 1 || cnt[node] >= th)
                continue;
            ++cnt[node];
            vis[node] = 1;
            ans = Math.max(ans,wt);
            for(int i=0;i<g[node].size();i++)
            {
                int[] nbr =  g[node].get(i);
                q.add(nbr);
            }
        }
        for(int i=0;i<n;i++)
            if(vis[i] == 0)
                return -1;
        return ans;
    }
}
```
['Java']