摘要:
完全背包 import java.util.Arrays; class Solution { public int coinChange(int[] coins, int amount) { /** * dp[j]定义为总金额为j时最少的硬币数量 * 因为是求最小值,因此所有位置初始化为最大值 * 阅读全文
posted @ 2022-01-26 14:30
振袖秋枫问红叶
阅读(26)
评论(0)
推荐(0)
摘要:
完全背包 class Solution { public int combinationSum4(int[] nums, int target) { /** * dp[i]定义为总和为i时排列的数量 * 初始dp[0] == 1 */ int[] dp = new int[target + 1]; 阅读全文
posted @ 2022-01-26 11:04
振袖秋枫问红叶
阅读(32)
评论(0)
推荐(0)
摘要:
完全背包 class Solution { public int change(int amount, int[] coins) { /** * dp[j]定义为总金额为j时组合的方式数量 * 初始dp[0] == 1 */ int[] dp = new int[amount + 1]; dp[0] 阅读全文
posted @ 2022-01-26 10:33
振袖秋枫问红叶
阅读(33)
评论(0)
推荐(0)