Implement prototype(costs: list[list[int | None]]) -> int | None and solve with the same signature. The matrix must be square and symmetric. Integer entries are undirected edge costs; None means no edge. Zero and negative costs are valid. Diagonal entries are ignored after shape/symmetry validation.

Return the minimum spanning-tree total, or None if disconnected. [] returns 0. Example: [[0,2,8],[2,0,1],[8,1,0]] returns 3.

Raise ValueError for a nonsquare or asymmetric matrix. Prototype: convert to edges and use an MST method. Final: use an array frontier with O(V²) time and O(V) auxiliary space. Preserve every row, including on failure.

Drag or use the arrow keys to resize. Home collapses the question; End collapses the editor. Enter or double-click resets the split.
Loading editor…
No results yet.

Complete the starter code, then run the checks.
Results and errors will appear here.