The problem description is quite confusing isn't it?

  • 2

    The matrix representation is a bit confusing by looking at it. It appears to be asking to number the disjoint sets in the graph. But what it actually asks is who are forming a single disjoint set and how many disjoint sets are there. M[i][i] can simply be ignored. M[i][j] means i and j are connected.

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.