Binary Search + BFS/DFS
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:
    bool isValid(int n, vector<vector<int>> &edges, int threshold, int mid, vector<vector<pair<int, int>>> &adj)
    {
        vector<int> visited(n, 0);
        queue<int> q;
        q.push(0);
        visited[0] = 1;
        int count = 0;

        while (!q.empty())
        {
            int node = q.front();
            q.pop();
            count++;

            for (auto it : adj[node])
            {
                if (!visited[it.first] and it.second <= mid)
                {
                    q.push(it.first);
                    visited[it.first] = 1;
                }
            }
        }
        return count == n;
    }

    int minMaxWeight(int n, vector<vector<int>> &edges, int threshold)
    {
        vector<vector<pair<int, int>>> adj(n);
        for (auto it : edges)
        {
            int u = it[0];
            int v = it[1];
            int wt = it[2];
            adj[v].push_back({u, wt});
        }

        int mx = 0;
        for (auto it : edges)
        {
            mx = max(mx, it[2]);
        }

        int lb = 0;
        int ub = mx;
        int ans = 1e9;

        while (lb <= ub)
        {
            int mid = lb + (ub - lb) / 2;
            if (isValid(n, edges, threshold, mid, adj))
            {
                ans = mid;
                ub = mid - 1;
            }
            else
            {
                lb = mid + 1;
            }
        }
        if(ans == 1e9) return -1;
        return ans;
    }
};
```
['Binary Search', 'Depth-First Search', 'Breadth-First Search', 'Graph', 'C++']