Back to all patterns

DFS/BFS or Union Find

1 problems • Practice on LeetCode to earn credits

About This Pattern

Master the DFS/BFS or Union Find pattern by practicing these problems organized by difficulty.Focus on the Key Signals - these are the indicators that tell you when to use this pattern.

Medium (1)

Number of Connected Components In An Undirected Graph

Count number of connected components in an undirected graph.

Key Signals:

Visit unvisited nodesCount componentsUnion find alternative