문제 설명
https://programmers.co.kr/learn/courses/30/lessons/77485
풀이 코드
def find_min_num(graph, top, left, bottom, right):
top_left = graph[top][left]
min_num = top_left
for y in range(top, bottom):
graph[y][left] = graph[y+1][left]
min_num = min(min_num, graph[y][left])
for x in range(left, right):
graph[bottom][x] = graph[bottom][x+1]
min_num = min(min_num, graph[bottom][x])
for y in range(bottom, top, -1):
graph[y][right] = graph[y-1][right]
min_num = min(min_num, graph[y][right])
for x in range(right, left, -1):
graph[top][x] = graph[top][x-1]
min_num = min(min_num, graph[top][x])
graph[top][left+1] = top_left
return min_num
def solution(rows, columns, queries):
answer=[]
graph = [[i+(columns*j) for i in range(1, columns+1) ] for j in range(rows)]
for top, left, bottom, right in queries:
top, left, bottom, right = top-1, left-1, bottom-1, right-1
answer.append(find_min_num(graph, top, left, bottom, right))
return answer