-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpy2373.py
More file actions
21 lines (19 loc) · 717 Bytes
/
py2373.py
File metadata and controls
21 lines (19 loc) · 717 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
def largestLocal(grid: list[list[int]]) -> list[list[int]]:
res = []
for x in range(len(grid) - 2):
inside_res = []
for y in range(len(grid) - 2):
max_num = 0
for i in range(x, x + 3):
for j in range(y, y + 3):
if max_num < grid[i][j]:
max_num = grid[i][j]
inside_res.append(max_num)
res.append(inside_res)
return res
print(largestLocal([[9, 9, 8, 1], [5, 6, 2, 6], [8, 2, 6, 4], [6, 2, 2, 2]]))
print(largestLocal([[1, 1, 1, 1, 1],
[1, 1, 1, 1, 1],
[1, 1, 2, 1, 1],
[1, 1, 1, 1, 1],
[1, 1, 1, 1, 1]]))