Skip to content

Commit 2b3c83e

Browse files
authored
Merge pull request #787 from AlgorithmWithGod/suyeun84
[20250831] PGM / LV3 / 등굣길 / 김수연
2 parents 29779cd + 53f2f37 commit 2b3c83e

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
```java
2+
class Solution {
3+
public int solution(int m, int n, int[][] puddles) {
4+
int answer = 0;
5+
int[][] dp = new int[n+1][m+1];
6+
dp[1][1] = 1;
7+
for (int[] temp : puddles) {
8+
dp[temp[1]][temp[0]] = -1;
9+
}
10+
for (int i = 1; i < n+1; i++) {
11+
for (int j = 1; j < m+1; j++) {
12+
if (i == 1 && j == 1) continue;
13+
if (dp[i][j] == -1) continue;
14+
15+
if (dp[i][j-1] > 0) {
16+
dp[i][j] = (dp[i][j] + dp[i][j-1]) % 1000000007;
17+
}
18+
if (dp[i-1][j] > 0) {
19+
dp[i][j] = (dp[i][j] + dp[i-1][j]) % 1000000007;
20+
}
21+
}
22+
}
23+
return dp[n][m];
24+
}
25+
}
26+
```

0 commit comments

Comments
 (0)