Tap here to switch tabs
Problem
Submissions

Problem: Largest Plus Sign

med
30 min
Try to solve the Largest Plus Sign problem.

Statement

You are given an integer n representing the size of an n by n binary grid. All cells in the grid are initially set to 11, except for the coordinates provided in the 22D array mines, where each element mines[i] = [x_i, y_i] indicates that the cell at (x_i, y_i) contains a 00.

An axis aligned plus sign of order k centered at cell (r, c) consists of grid[r][c] = 1 along with four extending arms of length k−1k - 1 in the up, down, left, and right directions, where every cell along all four arms also contains a 11. Note that if k=1k = 1, the plus sign consists of just a single cell containing 11.

Return the order of the largest plus sign that can be formed in the grid. If no valid plus sign exists, return 00.

Constraints:

  • 1≤1 \leq n ≤500\leq 500

  • 1≤1 \leq mines.length ≤5000\leq 5000

  • 0≤0 \leq x_i, y_i << n

  • All the pairs (x_i, y_i) are unique.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Largest Plus Sign

med
30 min
Try to solve the Largest Plus Sign problem.

Statement

You are given an integer n representing the size of an n by n binary grid. All cells in the grid are initially set to 11, except for the coordinates provided in the 22D array mines, where each element mines[i] = [x_i, y_i] indicates that the cell at (x_i, y_i) contains a 00.

An axis aligned plus sign of order k centered at cell (r, c) consists of grid[r][c] = 1 along with four extending arms of length k−1k - 1 in the up, down, left, and right directions, where every cell along all four arms also contains a 11. Note that if k=1k = 1, the plus sign consists of just a single cell containing 11.

Return the order of the largest plus sign that can be formed in the grid. If no valid plus sign exists, return 00.

Constraints:

  • 1≤1 \leq n ≤500\leq 500

  • 1≤1 \leq mines.length ≤5000\leq 5000

  • 0≤0 \leq x_i, y_i << n

  • All the pairs (x_i, y_i) are unique.