MST || PRIMS || SIMPLE
IntuitionThe intution is simple , They want to form a 0 Rooted tree ,
Reverset the edges, use MST algo (I have used prims's algo)
Why MST : the greey approach o
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
The intution is simple , They want to form a 0 Rooted tree ,
Reverset the edges, use MST algo (I have used prims's algo) 
Why MST : the greey approach of taking the minimum weight edges will work here too .
The threshold is just a dummy variable , think if any node is unreachble from 0 then return -1 , else it just need one parent to become reachble from 0 , (in original graph this mean only one outgoing edge is needed at most to get 0 ) so why need 2 or k edges


# Approach
<!-- Describe your approach to solving the problem. -->
Just implement prims 

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```cpp []
class Solution {
public:
    int minMaxWeight(int n, vector<vector<int>>& edges, int threshold) {
        int mn=0;
        vector<int>vis(n);
        vector<vector<vector<int>>>invg(n);
        for(auto i:edges){
            invg[i[1]].push_back({i[2],i[0]}); // reversing the edges 
        }
        priority_queue<vector<int>,vector<vector<int>>,greater<vector<int>>>pq; // to get lower weight edge first
        pq.push({0,0});
        while(pq.size()){
            auto node=pq.top()[1],w=pq.top()[0];
            pq.pop();
            if(vis[node])continue;
            vis[node]=1;
            mn=max(mn,w); // geting the biggest weight edge till now 
            for(auto i:invg[node]){
                if(!vis[i[1]])
                pq.push(i);
            }
        }
        for(auto i:vis)if(i==0)return -1; // if any node is just unreachble then return -1 
        return mn;  
    }
};
```
['Greedy', 'Graph', 'Heap (Priority Queue)', 'Minimum Spanning Tree', 'C++']