Learn
Practice
Interview
Resources
Newsletter
F
Toggle theme
0
F
0
Toggle menu
Animations
← Back to All Animations
947. Most Stones Removed with Same Row or Column
Bookmark
DFS
Union Find
Input
6 Stones (ans=4)
5 Stones (ans=3)
3 Stones (ans=2)
3 Stones Diag (ans=0)
Custom
stones
=
[[0,0],[0,1],[1,0],[1,2],[2,1],[2,2]]
0
1
2
0
1
2
Row
Col
(0,0)
(0,1)
(1,0)
(1,2)
(2,1)
(2,2)
Stones: 6
Components: 0
Removable: 0
0
1
2
0
1
2
Row
Col
(0,0)
(0,1)
(1,0)
(1,2)
(2,1)
(2,2)
Stones: 6
Components: 0
Removable: 0
0
1
2
0
1
2
Row
Col
(0,0)
(0,1)
(1,0)
(1,2)
(2,1)
(2,2)
Stones: 6
Components: 0
Removable: 0
0
1
2
0
1
2
Row
Col
(0,0)
(0,1)
(1,0)
(1,2)
(2,1)
(2,2)
Stones: 6
Components: 0
Removable: 0
0
1
2
0
1
2
Row
Col
(0,0)
(0,1)
(1,0)
(1,2)
(2,1)
(2,2)
Stones: 6
Components: 0
Removable: 0
0
1
2
0
1
2
Row
Col
(0,0)
(0,1)
(1,0)
(1,2)
(2,1)
(2,2)
Stones: 6
Components: 0
Removable: 0
0
1
2
0
1
2
Row
Col
(0,0)
(0,1)
(1,0)
(1,2)
(2,1)
(2,2)
Stones: 6
Components: 0
Removable: 0
0
1
2
0
1
2
Row
Col
(0,0)
(0,1)
(1,0)
(1,2)
(2,1)
(2,2)
Stones: 6
Components: 0
Removable: 0
0
1
2
0
1
2
Row
Col
(0,0)
(0,1)
(1,0)
(1,2)
(2,1)
(2,2)
Stones: 6
Components: 0
Removable: 0
0
1
2
0
1
2
Row
Col
(0,0)
(0,1)
(1,0)
(1,2)
(2,1)
(2,2)
Stones: 6
Components: 1
Removable: 0
0
1
2
0
1
2
Row
Col
(0,0)
(0,1)
(1,0)
(1,2)
(2,1)
(2,2)
Stones: 6
Components: 1
Removable: 5
algo
master
.
io
Step:
Given 6 stones on a 2D plane. Build a graph linking stones that share a row or column, then count its components.
0 / 49
Input
6 Stones (ans=4)
5 Stones (ans=3)
3 Stones (ans=2)
3 Stones Diag (ans=0)
Custom
stones
=
[[0,0],[0,1],[1,0],[1,2],[2,1],[2,2]]
0 / 49
algo
master
.
io
Step:
Given 6 stones on a 2D plane. Build a graph linking stones that share a row or column, then count its components.