All prompts are owned by LeetCode. To view the prompt, click the title link above.
Completed during Weekly Contest 403 (q2)
First completed : July 07, 2024
Last updated : July 07, 2024
Related Topics : Array, Matrix
Acceptance Rate : 73.0 %
class Solution:
def minimumArea(self, grid: List[List[int]]) -> int:
for r in grid :
print(r)
rowMin, rowMax = inf, -inf
colMin, colMax = inf, -inf
found = False
for r in range(len(grid)) :
for c in range(len(grid[0])) :
if grid[r][c] :
# print(f'{r, c = }')
found = True
if r < rowMin :
rowMin = r
if r > rowMax :
rowMax = r
if c < colMin :
colMin = c
if c > colMax :
colMax = c
if not found :
return 0
return max((colMax - colMin + 1), 1) * max((rowMax - rowMin + 1), 1)