Quiz: Counting Components

Test your understanding

Check Your Understanding

With n cities and Union-Find, how do you count the number of provinces?

  1. A.Count the number of edges in the graph
  2. B.Start with n components, subtract 1 for each successful union
  3. C.Count nodes where parent[i] == i
  4. D.Run DFS from every node and count visits
Start the roadmap to answer the quizzes and solve the challenges