Prototype: implement prototype(Long[][] costs) returning Long with a direct baseline.

Final: implement solve(Long[][] costs) with the mechanism and bounds described above. Require a square, symmetric Long matrix (null means no edge), otherwise IllegalArgumentException. Validate symmetry before ignoring diagonal values. Return the minimum spanning-tree total or null if disconnected. Empty matrix returns 0L. Prototype may convert to an edge list and apply an MST algorithm. Both stages have the same observable contract. The prototype may use the simpler method; final must use the target data structure.

All methods are static members of Exercise.

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.

Java runs on this device with CheerpJ 4.3.