Skip to content

[4주차] 배수빈 #46

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Oct 6, 2024
Prev Previous commit
Next Next commit
배수빈: [PG] 42898 등굣길_241003
  • Loading branch information
baexxbin committed Oct 3, 2024
commit afd6eb0cbe1db36ac430a2badc831eb41f3d6d82
25 changes: 25 additions & 0 deletions Programmers/Level3/SB_ 42898.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import java.util.*;

class Solution {
private static int MOD = 1000000007;
public int solution(int m, int n, int[][] puddles) {
int[][] dp = new int[n+1][m+1];

for(int[] p: puddles){
dp[p[1]][p[0]] = -1;
}

dp[1][1] = 1;
for(int i=1; i<n+1; i++){
for(int j=1; j<m+1; j++){
if(dp[i][j]==-1) {
dp[i][j] = 0;
continue;
}
dp[i][j] += (dp[i-1][j]+dp[i][j-1])%MOD;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

우와 점화식 진짜 깔끔하시네요...!
저는 위쪽에서 오는 경우의 수, 아래에서 오는 경우의 수 나눠서 풀었는데 그냥 바로 이렇게 해도되는군요👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

넵! 최종적으론 위에서 오는 경우랑 오른쪽에서 오는 경우를 합해야하기에 같이 더해줬습니다!👍

}
}
return dp[n][m]%MOD;

}
}