Number of Connected Components in an Undirected Graph

Editorial
Union FindGraphBreadth First SearchDepth First Search