Number of Connected Components in an Undirected Graph

Given n nodes (labeled from 0 to n-1) and a list of undirected edges, return the number of connected components in the graph.

Two nodes are connected if there's a path between them.

Examples
Input: [5,[[0,1],[1,2],[3,4]]]
Output: 2
Hints

Number of Connected Components in an Undirected Graph

Given n nodes (labeled from 0 to n-1) and a list of undirected edges, return the number of connected components in the graph.