Given an undirected graph with n nodes and a list of edges, return the number of connected components (maximal groups of mutually reachable nodes; isolated nodes count as their own component). The input is JSON {n, edges}.
Input: JSON {n, edges}.
Output: Integer — the number of connected components.
Input: {"n":5,"edges":[[0,1],[2,3]]}
Output: 3
Explanation: Components {0,1},{2,3},{4}.Input: {"n":1,"edges":[]}
Output: 1
Explanation: Single node.Input: {"n":3,"edges":[[0,1],[1,2]]}
Output: 1
Explanation: All connected.1<=n<=10^5undirected