Solution to Exercise 4: Finding the Best Connection

Solve Exercise 4 of this chapter.

In this exercise, we need to find the largest subset of cities that have a direct road between any pair of them.

The following illustration can be helpful to understand what we want:

Get hands-on with 1400+ tech skills courses.