Deep Dive
Kruskal + Union-Find
1584. Min Cost to Connect All Points · Spanning trees · 75 of 78
1/8
Connect every city
In this lessonStep 1 of 8 · ← → keys
The question
Join every city with roads so the total cost is as small as possible. Kruskal sorts the roads and keeps each one that joins two different groups. Union-Find tells us which group a city is in.