Loading...
You are given an integer n and a 2D array zeros. An n x n binary grid starts filled with 1s; the cells listed in zeros (as [row, col] pairs) are set to 0.
A plus of order k is a cell equal to 1 together with four straight arms of k - 1 consecutive 1s extending up, down, left, and right from it. Cells beyond the four arms are irrelevant. A single 1 cell is a plus of order 1.
Return the largest order of any plus in the grid, or 0 if the grid contains no 1 at all.
Input: n = 5, zeros = [[4,2]]
Output: 2
Explanation: With only one zero in the bottom row, no order-3 plus fits: its down arm or side arm always leaves the grid or is unneeded; the best center makes an order-2 plus.
Input: n = 1, zeros = [[0,0]]
Output: 0
Explanation: The only cell is 0.
zeros.length ≤5000row, col <nzeros cells are distinct.Click "Run" to test with sample cases or "Submit" to run all tests.