Skip to content

Commit 8c58e21

Browse files
committed
106차 3번 문제풀이
1 parent 1588178 commit 8c58e21

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
def solution(m, n, puddles):
2+
graph = [[-1] * m for _ in range(n)]
3+
4+
graph[0][0] = 1
5+
6+
# 웅덩이 체크
7+
for x, y in puddles:
8+
graph[y - 1][x - 1] = 0
9+
10+
# 첫 열 초기화
11+
for i in range(1, n):
12+
if graph[i][0] == 0:
13+
graph[i][0] = 0
14+
else:
15+
graph[i][0] = graph[i - 1][0]
16+
17+
# 첫 행 초기화
18+
for j in range(1, m):
19+
if graph[0][j] == 0:
20+
graph[0][j] = 0
21+
else:
22+
graph[0][j] = graph[0][j - 1]
23+
24+
# 웅덩이 제외 경로 계산
25+
for i in range(1, n):
26+
for j in range(1, m):
27+
if graph[i][j] != 0:
28+
graph[i][j] = graph[i-1][j] + graph[i][j-1]
29+
30+
return graph[n-1][m-1] % 1000000007

0 commit comments

Comments
 (0)