2024/12/3 灵茶题单 dp

This commit is contained in:
Cool 2024-12-03 17:00:59 +08:00
parent 61bf855b75
commit 0784c9f188
1 changed files with 16 additions and 0 deletions

View File

@ -0,0 +1,16 @@
package com.cool.ling_cha_mount.dp;
public class Num377 {
public int combinationSum4(int[] nums, int target) {
int[] dp=new int[target+1];
dp[0]=1;
for(int i=1;i<dp.length;i++){
for(int num:nums){
if(num<=i){
dp[i]+=dp[i-num];
}
}
}
return dp[target];
}
}