Simple Binary Search 
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
```python3 []
from collections import deque, defaultdict

class Solution:
    def minMaxWeight(self, n, edges, threshold):
        # Create the adjacency list
        graph = defaultdict(list)
        max_weight = 0
        
        # Populate the graph
        for u, v, w in edges:
            graph[v].append((u, w))  # Create incoming edges
            max_weight = max(max_weight, w)
        
        def bfs(mid):
            visited = [0] * n
            queue = deque([0])
            visited[0] = 1
            count = 1
            
            while queue:
                node = queue.popleft()
                if count == n:
                    return True

                for neighbor, weight in graph[node]:
                    if weight <= mid and not visited[neighbor]:
                        visited[neighbor] = 1
                        count += 1
                        queue.append(neighbor)

            # Check if each node has at most `threshold` incoming edges
            for node in range(n):
                incoming_count = sum(1 for _, weight in graph[node] if weight <= mid)
                if incoming_count > threshold:
                    return False

            return count == n

        # If the max_weight BFS traversal fails, return -1
        if not bfs(max_weight):
            return -1
        
        # Binary search to find the minimum max weight
        lo, hi = 0, max_weight
        answer = max_weight
        
        while lo <= hi:
            mid = (lo + hi) // 2
            if bfs(mid):
                answer = mid
                hi = mid - 1
            else:
                lo = mid + 1
        
        return answer

```
['Python3']