Class Solution
java.lang.Object
g1101_1200.s1139_largest_1_bordered_square.Solution
1139 - Largest 1-Bordered Square.<p>Medium</p>
<p>Given a 2D <code>grid</code> of <code>0</code>s and <code>1</code>s, return the number of elements in the largest <strong>square</strong> subgrid that has all <code>1</code>s on its <strong>border</strong> , or <code>0</code> if such a subgrid doesn’t exist in the <code>grid</code>.</p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> grid = [[1,1,1],[1,0,1],[1,1,1]]</p>
<p><strong>Output:</strong> 9</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> grid = [[1,1,0,0]]</p>
<p><strong>Output:</strong> 1</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= grid.length <= 100</code></li>
<li><code>1 <= grid[0].length <= 100</code></li>
<li><code>grid[i][j]</code> is <code>0</code> or <code>1</code></li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
largest1BorderedSquare
public int largest1BorderedSquare(int[][] grid)
-