Step 1: It's easy to realize that if cost of library is less than cost of road, we will construct a library for each city. Step 2: If it's not step1-case, we will try to create and count how many ...
// 3. UnionFind - find the parent of both nodes, if same reutn false; // In UnionFind the complexity is better because it has been verified at the time of adding edges ...