Medium · Graphs
Number of Connected Components
You are given a number of points, numbered from 0, and a list of pairs [a, b] that are joined by a line. Return how many separate groups of joined points there are.
- A point joined to nothing is a group of its own.
- Lines go both ways.
- No pair is listed twice.
points = 5 lines = [[0, 1], [1, 2], [3, 4]] → 2Record your take