Skip to main content
Admissions guidance, study banks, and career tools — get started on Shalyam

Number of Provinces

Given an n x n matrix isConnected where isConnected[i][j] = 1 means city i and city j are directly connected, print the number of provinces (groups of directly or indirectly connected cities).

Constraints

1 <= n <= 200

Discussion

No discussions yet.

Rewards · v2.1

Get Exclusive Insights with Every Issue

Join Shalyam Newsletter

Stay ahead in education, research, and innovation—straight to your inbox.