Learn
Practice
Interview
Resources
Newsletter
F
Toggle theme
0
F
0
Toggle menu
Animations
← Back to All Animations
305. Number of Islands II
Bookmark
BFS After Each Op
Union Find
Input
3x3 Merge
2x2 Full
3x3 Corners
Custom
m
=
3
,
n
=
3
,
positions
=
[[0,0],[0,1],[1,2],[2,1],[1,1]]
Islands: 0
0
1
2
0
1
2
Water
Active
Island A
Island B
Island C
Islands: 0
0
1
2
0
1
2
Water
Active
Island A
Island B
Island C
Islands: 1
0
1
2
0
1
2
L
Water
Active
Island A
Island B
Island C
Islands: 1
0
1
2
0
1
2
L
L
result:
1
0
Water
Active
Island A
Island B
Island C
Islands: 1
0
1
2
0
1
2
L
L
L
result:
1
0
1
1
Water
Active
Island A
Island B
Island C
Islands: 2
0
1
2
0
1
2
L
L
L
result:
1
0
1
1
Water
Active
Island A
Island B
Island C
Islands: 1
0
1
2
0
1
2
L
L
L
L
result:
1
0
1
1
2
2
Water
Active
Island A
Island B
Island C
Islands: 3
0
1
2
0
1
2
L
L
L
L
result:
1
0
1
1
2
2
Water
Active
Island A
Island B
Island C
Islands: 1
0
1
2
0
1
2
L
L
L
L
L
result:
1
0
1
1
2
2
3
3
Water
Active
Island A
Island B
Island C
Islands: 1
0
1
2
0
1
2
L
L
L
L
L
result:
1
0
1
1
2
2
3
3
Water
Active
Island A
Island B
Island C
Islands: 1
0
1
2
0
1
2
L
L
L
L
L
result:
1
0
1
1
2
2
3
3
1
4
Water
Active
Island A
Island B
Island C
algo
master
.
io
Step:
Start from an empty 3 x 3 grid with no islands
0 / 151
Input
3x3 Merge
2x2 Full
3x3 Corners
Custom
m
=
3
,
n
=
3
,
positions
=
[[0,0],[0,1],[1,2],[2,1],[1,1]]
0 / 151
algo
master
.
io
Step:
Start from an empty 3 x 3 grid with no islands