Implement Prototype(n int,edges [][3]int) (*MST,error) using sorted candidates plus DFS connectivity; Solve uses DSU with compression and size/rank. Normalize undirected endpoints (min,max,weight), sort by (weight,min,max), accept noncycles in that order. Signed weights valid. Return nil if disconnected, {0,[]} for valid n=0/1. Error for negative n or invalid endpoints. Preserve input; accepted edges are detached storage.

Edit exercise.go; retain the public types and signatures. prototype and final are separate stages. The executable tests recover panics as failures, report named checks, and exit nonzero on any failure. A successful run must execute at least one check. Tests use logical time or explicit synchronization where relevant.

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.