Binary Search + DFS
Code
# Code
```cpp []
class Solution {
public:
    static bool cmp(vector<int> &edge1, vector<int> &edge2) {
        return edge1[2] < edge2[2];
    }
    // Slight optimisation to find the right index with sorted edges
    int find_index(int val, vector<vector<int>>& edges) {
        auto it = std::upper_bound(edges.begin(), edges.end(), std::vector<int>{0, 0, val}, 
                               [](const std::vector<int>& a, const std::vector<int>& b) {
                                   return a[2] < b[2];
                               });
        
        if (it != edges.end()) {
            int index = it - edges.begin();
            return max(index - 1, 0);
        } else {
            return edges.size() - 1;
        }
    }
    // Greedy DFS as we want to minimise the number of outgoing edges from each node
    void dfs(int s, int par, vector<vector<int>>& adj, vector<int>& visited, vector<int>& outgoing, int& total) {
        visited[s] = 1;
        total++;
        for(auto itr: adj[s]) {
            if(visited[itr] == 0) {
                outgoing[itr]++;
                dfs(itr, s, adj, visited, outgoing, total);
            }
        }
    }
    bool isValid(int mid, int n, int threshold, vector<vector<int>>& edges) {
        // Create a reverse graph for doing dfs from node 0
        vector<vector<int>> rev(n);
        int index = find_index(mid, edges);
        for(int i = 0; i <= index; i++) {
            if(edges[i][2] <= mid) {
                rev[edges[i][1]].push_back(edges[i][0]);
            }
        }
        vector<int>visited(n);
        vector<int>outgoing(n, 0);
        int total = 0;
        dfs(0, -1, rev, visited, outgoing, total);
        // Check if all nodes are covered in dfs
        if(total < n) return false;

        // check if all nodes have atmost threshold outgoing edges
        for(int i = 0; i < n; i++) {
            if(outgoing[i] > threshold) return false;
        }
        return true;
    }
    int minMaxWeight(int n, vector<vector<int>>& edges, int threshold) {
        sort(edges.begin(), edges.end(), cmp);
        int maxWeight = INT_MIN;
        for(auto edge: edges) {
            maxWeight = max(maxWeight, edge[2]);
        }
        int low = 0;
        int high = maxWeight;
        int ans = -1;
        while(low <= high) {
            int mid = low + (high - low) / 2;
            if(isValid(mid, n, threshold, edges)) {
                ans = mid;
                high = mid - 1;
            } else {
                low = mid + 1;
            }
        }
        return ans;
    }
};
```
['C++']