Easy BFS Solution | CPP | O(N)
IntuitionWe need to traverse the graph while maintaining the maximum weight encountered so far, updating the relevant values as we go. Finally, we need to deter
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
We need to traverse the graph while maintaining the maximum weight encountered so far, updating the relevant values as we go. Finally, we need to determine the maximum value from the resulting array.

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

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

# Code
```cpp []
class Solution {
public:
    int minMaxWeight(int n, vector<vector<int>>& edges, int threshold) {
        vector<vector<pair<int,int>>> adj(n,vector<pair<int,int>>());
        for(vector<int> i: edges){
            adj[i[1]].push_back({i[0],i[2]});
        }
        vector<int> a(n,INT_MAX);
        queue<pair<int,int>> q;

        q.push({0,INT_MIN});

        while(!q.empty()){
            int s = q.size();
            for(int i = 0; i < s;i++){
                pair<int,int> p = q.front();
                a[p.first] = min(p.second,a[p.first]);
                q.pop();
                for(pair<int,int> t : adj[p.first]){
                    if( t.first != 0 && a[t.first]  > max(t.second,p.second)){q.push({t.first,max(t.second,p.second)});}
                }
            }
        }
        int mx = INT_MIN;
        for(int i = 1; i < a.size(); i++){
            mx = max(mx,a[i]);
        }
        if(mx == INT_MAX) return -1;
        return mx;

    }
};
```
['Breadth-First Search', 'Graph', 'Queue', 'C++']