Reverse Graph | Prism MST Algorithm | Intuitive Approach
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

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

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

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

# Code
```cpp []
class Solution {
public:
    int MST(unordered_map<int,vector<pair<int,int>> > &adj,int n,vector<int> &visited){

        priority_queue<pair<int, int>, vector<pair<int, int>>,    greater<pair<int, int>>> pq;
        
        pq.push({0,0}); // {wt,node}
        int maxWt = -1;
        while(!pq.empty()){
            int node = pq.top().second;
            int wt = pq.top().first;

            pq.pop();

            if(visited[node]) continue;
            visited[node]=1;
            maxWt=max(maxWt,wt);

            for(auto it : adj[node]){
                int v = it.first;
                int ed_Wt = it.second;   
                if(!visited[v]){
                    pq.push({ed_Wt,v});
                }         
            }
        }
        for(int i=0;i<n;i++){
            if(!visited[i]) return -1;
        }
        return maxWt;
    }
    int minMaxWeight(int n, vector<vector<int>>& edges, int threshold) {
        unordered_map<int,vector<pair<int,int>> > adj;

        for(auto it : edges){
            int u = it[0];
            int v = it[1];
            int wt = it[2];

            adj[v].push_back({u,wt});

        }
        vector<int> visited(n,0);

        return MST(adj,n,visited);
        

    }
};
```
['Breadth-First Search', 'Heap (Priority Queue)', 'Minimum Spanning Tree', 'C++']