Minimum spanning tree: Given an undirected weighted graph, return the total weight of a minimum spanning tree, or null when all nodes cannot be connected.
Input: A JSON object { "n": number, "edges": [number,number,number][] }.
Output: A JSON number or null.
Constraints:
- 0 <= n <= 100000
- Weights are safe integers and may be equal
- Parallel edges are allowed
Read one JSON value from stdin and print exactly one JSON-serialized answer to stdout with no extra text.
Difficulty: HARD. Variant: 15. Balance correctness, maintainability, and clear review-ready code.
Practice context
This coding (algo) exercise trains prompt interpretation, explicit assumptions, a concrete response, and a concise explanation of the decisions made. It is marked hard difficulty.
The signed-in workspace provides the tools required by the round, such as recording, code execution, diagrams, structured n