We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 718b5cd + b2ed5eb commit 929fca5Copy full SHA for 929fca5
1 file changed
suyeun84/202509/22 PGM LV3 거스름돈.md
@@ -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