There are nodes in an undirected graph, and a number of edges connecting some nodes. In each edge, the first value will be between and , inclusive. The second node will be between and , inclusive. Given a list of edges, determine the size of the smallest and largest connected components that have or more nodes. A node can have any number of connections. The highest node value will always be connected to at least other node.
Single nodes should not be considered in the answer.
The smaller component contains nodes and the larger contains . Return the array .
Complete the connectedComponents function in the editor below.
connectedComponents has the following parameter(s):
- int bg[n]: a 2-d array of integers that represent node ends of graph edges
- int: an array with 2 integers, the smallest and largest component sizes
The first line contains an integer , the size of .
Each of the next lines contain two space-separated integers, and .