shlogg · Early preview
Md Ariful Haque @mah-shamim

Most Stones Removed With Same Row Or Column

Remove max stones by DFS: iterate over stones, mark connected components with DFS, return total stones - numComponents

947. Most Stones Removed with Same Row or Column
Difficulty: Medium
Topics: Hash Table, Depth-First Search, Union Find, Graph
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: stones = [[0,0],[0,1],[1,0],[1,2],[2,1],[2,2]]
Ou...