Most Stones Removed with Same Row or Column
On a 2D plane, we place n stones at some integer coordinate points. Each coordinate point may have at most one stone. A stone can be removed if it shares either the same row or the same column as another stone that has not been removed. Given an array stones of length n where stones[i] = [xi, yi] represents the location of the ith stone, return the largest possible number of stones that can be removed.
Most Stones Removed with Same Row or Column

On a 2D plane, we place n stones at some integer coordinate points. Each coordinate point may have at most one stone. A stone can be removed if it shares either the same row or the same column as another stone that has not been removed. Given an array stones of length n where stones[i] = [xi, yi] represents the location of the ith stone, return the largest possible number of stones that can be removed.

Example 1:
Input: [[0,0],[0,1],[1,0],[1,2],[2,1],[2,2]]
Output: 5
Input
arr =[[0,0],[0,1],[1,0],[1,2],[2,1],[2,2]]

Starting with 6 stones. Each stone is its own component.

Stone Positions
0
1
2
3
4
5
x→y↓
Union-Find Stats
Total Stones
6
Components
6
Can Remove
0
Connected Components
Group 1: 1 stones
Group 2: 1 stones
Group 3: 1 stones
Group 4: 1 stones
Group 5: 1 stones
Group 6: 1 stones

Formula: removable = total - components = 6 - 6 = 0

Variables
No variables to display
DepthFunction Call
Stack empty
0/7