Count Connected Components

Graphs ยท medium

Given `n` nodes labeled `0..n-1` and an undirected `edges` list of `[a, b]` pairs, implement `countComponents(n, edges)` returning the number of connected components.

Learning resources

Loading...

Run your code to see results.