美文网首页
剑指 Offer II 104. 排列的数目

剑指 Offer II 104. 排列的数目

作者: 邦_ | 来源:发表于2022-09-01 10:20 被阅读0次

换下顺序就是排列数??


 func combinationSum4(_ nums: [Int], _ target: Int) -> Int {
        var dp = Array.init(repeating: 0, count: target + 1)
        dp[0] = 1
        for i in 0...target {
            for num in nums {
                if i < num || dp[i] > Int.max - dp[i - num]{
                   continue
                }
                dp[i] += dp[i - num]
            }
            
        }
                
        return dp.last!
    }







相关文章

网友评论

      本文标题:剑指 Offer II 104. 排列的数目

      本文链接:https://www.haomeiwen.com/subject/ouqtgrtx.html