We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 58960cb commit 8fea871Copy full SHA for 8fea871
ksinji/202510/30 PGM 등굣길.md
@@ -0,0 +1,34 @@
1
+```java
2
+class Solution {
3
+ static final int MOD = 1000000007;
4
+ public int solution(int m, int n, int[][] puddles) {
5
+ int[][] dp = new int[n+1][m+1];
6
+
7
+ dp[1][1] = 1;
8
9
+ for (int[] p: puddles){
10
+ dp[p[1]][p[0]] = -1;
11
+ }
12
13
+ for (int i=1; i<n+1; i++){
14
+ for (int j=1; j<m+1; j++){
15
+ if (i==1 && j==1){
16
+ continue;
17
18
19
+ if (dp[i][j] == -1) {
20
21
+ } else if (dp[i-1][j] == -1) {
22
+ dp[i][j] = dp[i][j-1]%MOD;
23
+ } else if (dp[i][j-1] == -1) {
24
+ dp[i][j] = dp[i-1][j]%MOD;
25
+ } else {
26
+ dp[i][j] = (dp[i][j-1]+dp[i-1][j])%MOD;
27
28
29
30
31
+ return dp[n][m];
32
33
+}
34
+```
0 commit comments