Graph theory puzzle about connectivity?

Try working in reverse order.

Add the edges one by one and use a disjoint set data structure to find when the set becomes connected.

Leave a Comment