Problem · Array
Largest Plus Sign
Learn this problemProblem statement
You have an n x n binary grid initially filled with ones. Every coordinate in mines is changed to zero.
An axis-aligned plus sign of order k has a center cell and four arms of ones extending k - 1 cells up, down, left, and right. Return the largest possible order. Return 0 if the grid contains no one.
Function
orderOfLargestPlusSign(n: int, mines: int[][]) → intExamples
Example 1
n = 5mines = [[4,2]]return = 2A plus centered at [2,2] has one cell in each arm, so its order is 2.
Example 2
n = 1mines = [[0,0]]return = 0The only cell is zero.
Constraints
1 <= n <= 500.0 <= mines.length <= n * n.- Every mine is a distinct pair
[row, col]with0 <= row, col < n.