Practice Largest 1-Bordered Square
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
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.
Source: Largest 1-Bordered Square on LeetCode. Use the original task for its coding environment and submissions.
Examples
# 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
1 <= grid.length <= 100
1 <= grid[0].length <= 100
grid[i][j] is 0 or 1
Related LeetCode Problems
Practice more problems similar to Largest 1-Bordered Square.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.