Skip to content

Latest commit

 

History

History
67 lines (34 loc) · 1.14 KB

File metadata and controls

67 lines (34 loc) · 1.14 KB

中文文档

Description

Given a 2D grid of 0s and 1s, return the number of elements in the largest square subgrid that has all 1s on its border, or 0 if such a subgrid doesn't exist in the grid.

 

Example 1:

Input: grid = [[1,1,1],[1,0,1],[1,1,1]]

Output: 9

Example 2:

Input: grid = [[1,1,0,0]]

Output: 1

 

Constraints:

    <li><code>1 &lt;= grid.length &lt;= 100</code></li>
    
    <li><code>1 &lt;= grid[0].length &lt;= 100</code></li>
    
    <li><code>grid[i][j]</code> is <code>0</code> or <code>1</code></li>
    

Solutions

Python3

Java

...