Skip to content

Commit 929fca5

Browse files
authored
[20250922] PGM / LV3 / 거스름돈 / 김수연
[20250922] PGM / LV3 / 거스름돈 / 김수연
2 parents 718b5cd + b2ed5eb commit 929fca5

File tree

1 file changed

+22
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)