Class Solution
- java.lang.Object
-
- g0701_0800.s0764_largest_plus_sign.Solution
-
public class Solution extends Object
764 - Largest Plus Sign.Medium
You are given an integer
n
. You have ann x n
binary gridgrid
with all values initially1
’s except for some indices given in the arraymines
. Theith
element of the arraymines
is defined asmines[i] = [xi, yi]
wheregrid[xi][y<sub>i</sub>] == 0
.Return the order of the largest axis-aligned plus sign of 1_’s contained in_
grid
. If there is none, return0
.An axis-aligned plus sign of
1
’s of orderk
has some centergrid[r][c] == 1
along with four arms of lengthk - 1
going up, down, left, and right, and made of1
’s. Note that there could be0
’s or1
’s beyond the arms of the plus sign, only the relevant area of the plus sign is checked for1
’s.Example 1:
Input: n = 5, mines = [[4,2]]
Output: 2
Explanation: In the above grid, the largest plus sign can only be of order 2. One of them is shown.
Example 2:
Input: n = 1, mines = [[0,0]]
Output: 0
Explanation: There is no plus sign, so return 0.
Constraints:
1 <= n <= 500
1 <= mines.length <= 5000
0 <= xi, yi < n
- All the pairs
(xi, yi)
are unique.
-
-
Constructor Summary
Constructors Constructor Description Solution()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
orderOfLargestPlusSign(int n, int[][] mines)
-