力扣 -- 377. 组合总和 Ⅳ

解题步骤:

参考代码:

cpp 复制代码
class Solution {
public:
    int combinationSum4(vector<int>& nums, int target) {

        int n=nums.size();
        vector<double> dp(target+1);

        //初始化
        dp[0]=1;

        //填表
        for(int i=1;i<=target;i++)
        {
            for(int j=0;j<n;j++)
            {
                //填表
                if(i>=nums[j])
                {
                    dp[i]+=dp[i-nums[j]];
                }
            }
        }
        //返回值
        return dp[target];
    }
};

你学会了吗???

相关推荐
劲夫学编程1 分钟前
leetcode: 字母异位词分组
算法·leetcode
星恒随风4 分钟前
C++11 加餐(3)并发支持库——atomic 原子操作与内存序详解
开发语言·c++·笔记
wy_hhxx21 分钟前
[Leetcode] 动态规划(打家劫舍、0-1背包、完全背包)
算法·leetcode·动态规划·完全背包·0-1背包
大袁同学31 分钟前
【Linux网络编程】:破局孤岛通四海,纵贯五层渡风云
linux·网络·c++·后端
fqbqrr34 分钟前
2612C++,C++20实战心得
c++·c++20
m0_547486661 小时前
《智能计算》全套课件PDF(武汉工程大学)
算法·贝叶斯算法·智能计算
白小飞不会飞1 小时前
【AUTOSAR】 E2E Transformer:把 E2E 库接到 RTE 上
c++·嵌入式硬件·车载系统·transformer·autosar
Shaoshing1 小时前
LeetCode100 32.最长有效括号
java·数据结构·leetcode
weixin_307779132 小时前
Jupyter SQL 表血缘分析并导出 Excel
开发语言·python·sql·算法·excel
Lazyafei2 小时前
560. 和为 K 的子数组
数据结构·算法