Practice Problem

Number of Connected Components

Difficulty: Medium

Given n nodes and a list of undirected edges, find the number of connected components in the graph.