Given an undirected graph with n vertices labelled 0 to n - 1 and a list of undirected edges, return the number of connected components. A component is a maximal set of vertices mutually reachable from one another.
The graph may be disconnected, may contain isolated vertices, and edges may repeat an edge or contain a self-loop ([v, v]).
Input: n = 5, edges = [[0,1],[1,2],[3,4]]
Output: 2
There are 2 components: {0,1,2} and {3,4}.
Input: n = 4, edges = []
Output: 4
With no edges, every vertex is its own component.
Input: n = 6, edges = [[0,1],[1,0],[2,2],[3,4],[4,5],[3,5]]
Output: 3
The repeated edge and the self-loop change nothing: the components are {0,1}, {2} and {3,4,5}.
1 <= n <= 10^50 <= edges.length <= 2 * 10^5edges[i].length == 2 and 0 <= edges[i][0], edges[i][1] < n