Tap here to switch tabs
Problem
Submissions

Problem: Most Stones Removed with Same Row or Column

Most Stones Removed with Same Row or Column gives you stones on a two-dimensional grid and asks for the maximum removable count, while each removed stone must share a row or column with one remaining.

Statement

Given an array of nn stones in a two-dimensional plane, where each stone is represented by a pair of x and y coordinates, find the maximum number of stones we can remove with the following condition:

A stone can be removed if it shares either the same row or the same column with another stone that has not been removed so far.

Stones are provided as an array, stones, of length nn, where stones[i]=[xi,yi]stones[i] = [x_i, y_i] represents the ithi^{th} stone. Return the maximum possible number of stones that can be removed.

Constraints:

  • 1≤1\leq stones.length ≤1000\leq 1000
  • 0≤xi,yi≤500\leq x_i, y_i \leq50
⋮
Tap here to switch tabs
Problem
Submissions

Problem: Most Stones Removed with Same Row or Column

Most Stones Removed with Same Row or Column gives you stones on a two-dimensional grid and asks for the maximum removable count, while each removed stone must share a row or column with one remaining.

Statement

Given an array of nn stones in a two-dimensional plane, where each stone is represented by a pair of x and y coordinates, find the maximum number of stones we can remove with the following condition:

A stone can be removed if it shares either the same row or the same column with another stone that has not been removed so far.

Stones are provided as an array, stones, of length nn, where stones[i]=[xi,yi]stones[i] = [x_i, y_i] represents the ithi^{th} stone. Return the maximum possible number of stones that can be removed.

Constraints:

  • 1≤1\leq stones.length ≤1000\leq 1000
  • 0≤xi,yi≤500\leq x_i, y_i \leq50