Brute Force
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)$$ -->

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

# Code
```cpp []
class Solution {
public:
    vector<vector<pair<int,int>>>adj;
    int cnt;
    bool flag;
    bool isPossible(int node,int maxWeight,vector<int>&visited,vector<int>&outEdges,int threshold){
        if(visited[node] == 0){
            visited[node] = 1;
            cnt--;
        }
        if(cnt == 0) return true;
        bool res = false;
        for(pair<int,int>&P : adj[node]){
            if(P.second <= maxWeight && visited[P.first] == 0) 
            { 
                outEdges[P.first]++;
                if(outEdges[P.first] > threshold) flag = false;
                res |= isPossible(P.first,maxWeight,visited,outEdges,threshold);
            }
        }
        return res;
    }


    int minMaxWeight(int n, vector<vector<int>>& edges, int threshold) {
        
        // int n = edges.size();
        adj.resize(n);
        
        set<int>st;
        int maxWeight = 0;
        for(vector<int>&e : edges){
            adj[e[1]].push_back({e[0],e[2]});
            maxWeight = max(maxWeight,e[2]);
            st.insert(e[2]);
        }
        vector<int>visited(n,0);
        vector<int>outEdges(n,0);
        vector<int>weights(begin(st),end(st));
        cnt = n;
        flag = true;

        int l = 0 , r = weights.size()-1;
        int res = -1;
        while(l <= r){
            int mid = l + (r-l)/2;
            maxWeight = weights[mid];
            vector<int>visited(n,0);
            vector<int>outEdges(n,0);
            cnt = n;
            flag = true;
            bool status = isPossible(0,maxWeight,visited,outEdges,threshold);
            if(status && flag){
                res = maxWeight;
                r = mid - 1;
            }
            else l = mid + 1;
        }

        return res;

    }
};
```
['C++']