DIY: Number of Connected Components in an Undirected Graph

Solve the interview question "Number of Connected Components in an Undirected Graph" in this lesson.

Problem statement

Suppose you are given an undirected graph with n nodes. You are also given an integer n and an array edges where edges[i] = [xi, yi] indicates that there is an edge between xi and ...

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.