Question
Given a connected-or-not undirected weighted graph with n nodes (0..n-1) and edges [w, u, v] (weight first), return the total weight of a maximum spanning tree: a spanning tree maximizing the sum of chosen edge weights. If the graph is not connected (no spanning tree exists), return -1. A single node with no edges has weight 0. Constraints: 1 <= n <= 1000.
max_spanning_tree_weight(n: int, edges: list[list[int]]) → int[3,[[1,0,1],[2,1,2],[3,0,2]]]out5State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.