[Programmers] 거스름돈 - 연습문제 (Dynamic Programming)

동민·2021년 3월 11일
0
// 거스름돈 - 연습문제 (Dynamic Programming)
public class Balance {
	public int solution(int n, int[] money) {
		int[] dp = new int[n + 1];
		dp[0] = 1;
		for (int i : money) {
			for (int j = i; j < n + 1; j++) {
				dp[j] = (dp[j] + dp[j - i]) % 1000000007;
			}
		}
		return dp[n];
	}
}

https://tosuccess.tistory.com/57 참고

profile
BE Developer

0개의 댓글