C# | O(nlog(n)) | Heap
Complexity

Time complexity: O(nlogn)


Space complexity: O(n)

Code
# Complexity
- Time complexity: O(nlogn)

- Space complexity: O(n)

# Code
```csharp []
public class Solution {
    public int MinMaxWeight(int n, int[][] edges, int threshold) {
        int max = int.MinValue;
        PriorityQueue<(int, int), int> pq = new();
        Dictionary<int, List<(int, int)>> adjMap = new();
        HashSet<int> notVisited = new HashSet<int>();
        for(int i = 0; i < n; i++)
        {
            notVisited.Add(i);
            adjMap.Add(i, new List<(int, int)>());
        }
        for(int i = 0; i < edges.Length; i++)
        {
            adjMap[edges[i][1]].Add((edges[i][0], edges[i][2]));
        }
        pq.Enqueue((0, 0), 0);
        while (pq.Count > 0 && notVisited.Count > 0)
        {
            (int currNode, int currWeight) = pq.Dequeue();
            if (!notVisited.Contains(currNode)) continue;
            notVisited.Remove(currNode);
            max = Math.Max(max, currWeight);
            foreach((int node, int weight) in adjMap[currNode])
            {
                pq.Enqueue((node, weight), weight);
            }
        }
        return notVisited.Count > 0 ? -1 : max;
    }
}
```
['Heap (Priority Queue)', 'Shortest Path', 'C#']