Class Solution
java.lang.Object
g0701_0800.s0764_largest_plus_sign.Solution
764 - Largest Plus Sign.<p>Medium</p>
<p>You are given an integer <code>n</code>. You have an <code>n x n</code> binary grid <code>grid</code> with all values initially <code>1</code>’s except for some indices given in the array <code>mines</code>. The <code>i<sup>th</sup></code> element of the array <code>mines</code> is defined as <code>mines[i] = [x<sub>i</sub>, y<sub>i</sub>]</code> where <code>grid[x<sub>i</sub>][y<sub>i</sub>] == 0</code>.</p>
<p>Return <em>the order of the largest <strong>axis-aligned</strong> plus sign of</em> 1_’s contained in_ <code>grid</code>. If there is none, return <code>0</code>.</p>
<p>An <strong>axis-aligned plus sign</strong> of <code>1</code>’s of order <code>k</code> has some center <code>grid[r][c] == 1</code> along with four arms of length <code>k - 1</code> going up, down, left, and right, and made of <code>1</code>’s. Note that there could be <code>0</code>’s or <code>1</code>’s beyond the arms of the plus sign, only the relevant area of the plus sign is checked for <code>1</code>’s.</p>
<p><strong>Example 1:</strong></p>
<p><img src="https://assets.leetcode.com/uploads/2021/06/13/plus1-grid.jpg" alt="" /></p>
<p><strong>Input:</strong> n = 5, mines = [[4,2]]</p>
<p><strong>Output:</strong> 2</p>
<p><strong>Explanation:</strong> In the above grid, the largest plus sign can only be of order 2. One of them is shown.</p>
<p><strong>Example 2:</strong></p>
<p><img src="https://assets.leetcode.com/uploads/2021/06/13/plus2-grid.jpg" alt="" /></p>
<p><strong>Input:</strong> n = 1, mines = [[0,0]]</p>
<p><strong>Output:</strong> 0</p>
<p><strong>Explanation:</strong> There is no plus sign, so return 0.</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= n <= 500</code></li>
<li><code>1 <= mines.length <= 5000</code></li>
<li><code>0 <= x<sub>i</sub>, y<sub>i</sub> < n</code></li>
<li>All the pairs <code>(x<sub>i</sub>, y<sub>i</sub>)</code> are <strong>unique</strong>.</li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
orderOfLargestPlusSign
public int orderOfLargestPlusSign(int n, int[][] mines)
-