-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathm3195 q2.py
29 lines (23 loc) · 838 Bytes
/
m3195 q2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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)