Learn
Practice
Newsletter
Resources
F
Toggle theme
0
F
Toggle theme
0
Toggle menu
← Back to All Animations
Number of Provinces
Bookmark
Input
2 Provinces
3 Provinces
1 Province
2 Provinces
Custom
isConnected
=
[[1,1,0],[1,1,0],[0,0,1]]
isConnected Matrix
0
1
2
0
1
1
0
1
1
1
0
2
0
0
1
City Connections
0
1
2
Union-Find Structure
Legend:
Standard
Checking
Active
Connected
algo
master
.
io
Step:
Given 3 cities with connection matrix. Find the number of provinces.
0 / 10
Input
2 Provinces
3 Provinces
1 Province
2 Provinces
Custom
isConnected
=
[[1,1,0],[1,1,0],[0,0,1]]
0 / 10
isConnected Matrix
0
1
2
0
1
1
0
1
1
1
0
2
0
0
1
City Connections
0
1
2
Union-Find Structure
Legend:
Standard
Checking
Active
Connected
algo
master
.
io
Step:
Given 3 cities with connection matrix. Find the number of provinces.