LeetCode 547: Number of Provinces, Turn an Adjacency Matrix into Connected Components
Problem Requirement You are given an n x n matrix isConnected, where there are n cities. If isConnected[i][j] == 1, city i and city j are directly connected. If two cities can reach each other through one or more directly connected cities, they belong to the same province. The problem asks you to return the total number of provinces. The easiest mistake is to think that the answer is the number of 1s in the matrix, or only the number of directly connected pairs. That is not what the problem asks. ...