-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathJW_42898.java
More file actions
19 lines (19 loc) Β· 894 Bytes
/
JW_42898.java
File metadata and controls
19 lines (19 loc) Β· 894 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
class JW_42898 {
final int MOD = 1_000_000_007; // λλ¨Έμ§ μ°μ°
public int solution(int m, int n, int[][] puddles) {
int[][] board = new int[n + 1][m + 1];
// μ
λ©μ΄κ° μλ μμΉ νμ
for (int[] puddle : puddles)
board[puddle[1]][puddle[0]] = -1;
board[0][1] = 1; // μμ μμΉμ μ νΉμ μΌμͺ½μ 1λ‘ μ΄κΈ°ν
for (int i = 1; i < n + 1; i++)
for (int j = 1; j < m + 1; j++)
// νμ¬ μμΉκ° μ
λ©μ΄κ° μλλΌλ©΄
if (board[i][j] != -1) {
int up = Math.max(0, board[i - 1][j]); // μμͺ½μμ μ€λ κ²½μ°
int lf = Math.max(0, board[i][j - 1]); // μΌμͺ½μμ μ€λ κ²½μ°
board[i][j] = (up + lf) % MOD; // κ°λ₯ν κ²½μ°μ μ κ³μ°
}
return board[n][m];
}
}